Thursday, March 27, 2014

Commonly Used Oracle Scripts

How to reset SYSTEM password for Oracle
RUN > sqlplus "/as sysdba"
alter user system account unlock;

How to set SYSTEM login password
alter user system identified by test;

Find count in a given table
This will display a count of all records in a given table. Conditions can also be added thru the where clause
Select count(*) from tablename

How to drop columns on a table
alter table
   table_name
drop column
   col_name1;  -- drop one column

alter table
   table_name
drop
   (col_name1, col_name2);  -- drop many columns

How to move tables
select 'ALTER TABLE TRIDATA_GRAINGER.' || TABLE_NAME || ' MOVE TABLESPACE TRIDATA_GRAINGER_DATA;'
from dba_tables
where owner = 'TRIDATA_GRAINGER'


and tablespace_name = 'TRIDATA_DATA'

No comments:

Post a Comment