Tuesday, December 16, 2008

Some Oracle commands

Renaming a table:
alter table oldname rename to newname;


Renaming a column:
alter table sometable rename column oldname to newname;


Return only a specified number of rows:
select * from mytable where rownum;


Make a backup copy of a table:
create table mytable_backup as select * from mytable;


Get a list of tables:
select * from cat;


Get the create command for a table (showing the primary key):
select dbms_metadata.get_ddl('TABLE',upper('MYTABLE')) from dual;


Change a user password:
alter user user_name identified by new_password;


Make things print to screen nicer:
set pagesize 0
set long 999999

0 comments:

Post a Comment