| | Select random row from Oracle table
Use this query to select a random record from Oracle table. This works from TOAD as well as sqlplus:
SELECT col_name
FROM
(SELECT col_name
FROM table_name
ORDER BY dbms_random.value)
WHERE rownum = 1;
| |  More... 02/16/06 | | | | | | | | |
|
| | Selecting random record
To select a random record from PostgreSQL table use the following SQL statement:
SELECT col_name
FROM table_name
ORDER BY random()
LIMIT 1;
| | More... 02/16/06 | | | | | | | | |
|
| | Find duplicate records query
Use the following SQL statement for finding duplicates in a table. I think this should work for any relational database, not only MySQL.
SELECT col_name, COUNT(col_name) AS num
FROM table_name
GROUP BY col_name
HAVING (COUNT(col_name) > 1);
| |  More... 02/16/06 | | | | | | | | |
|
|
| | Unregister snapshots
Script to generate sql to unregister snapshots in Oracle database
select 'exec DBMS_SNAPSHOT.UNREGISTER_SNAPSHOT(snapowner => ' || '''' || owner ||
'''' || ', snapname => ' || '''' || name || '''' || ', snapsite => ' || '''' ||
snapshot_site || '''' || ');'
from dba_registered_snapshots
/ | | More... 02/13/06 | | | | | | | | |
|
| | How to purge MySQL binary logs
You can put this command in crontab to run at regular intervals. This will purge database binary logs. $ designates shell prompt, replace passwd with the actual password.
$ /bin/echo 'reset master' | /usr/local/mysql/bin/mysql --password=passwd
| | More... 02/08/06 | | | | | | | | |
|
| | How to switch to another user
Need to become a different Oracle database user? There is a way to login into a another user's account without knowing their password:
1. Find out the encrypted password for the user
SQL> select username, password from dba_users where username = 'USERNAME';
USERNAME PASSWORD
------------ ------------------------------
USERNAME ... | |  More... 02/07/06 | | | | | | | | |
|
| | How to create externally identified user
This is an example how to create externally identified user in Oracle; i.e. if you want the os oracle user to connect to database without supplying password run the following statement from sqlplus:
SQL> create user OPS$ORACLE identified externally
default tablespace users
temporary ... | |  More... 02/07/06 | | | | | | | | |
|
| | Show system parameters on Solaris
The sysdef utility outputs the current system definition in tabular form. It lists all hardware devices, as well as pseudo devices, system devices, loadable modules, and the values of selected kernel tunable parameters.
$ /usr/sbin/sysdef
| | More... 02/06/06 | | | | | | | | |
|
| | How to kill Unix user session
One way to kill all sessions for a specific user is to run the following command (replace username with the actual user name):
kill -9 `ps -u username | grep -v PID | awk '{ printf ("%s ", $1); }'`
Of course you should only use the -9 option when you really ... | |  More... 01/25/06 | | | | | | | | |
|
<< 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Page 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 >> |