Wednesday, May 03, 2006

Snippet://Oracle/DUAL

Oracle Table DUAL
All Oracle accounts have access to a table called dual. You can query against this table to get the current account, system date/time, and excecute mathematical functions. For example
select user from dual;
select sysdate from dual;
select power(4,3) from dual;

Other Useful Commands
Use "Describe" To Get Table Definition
Use "Column" To Set Column Output Length
Use "Show All" and "Set" To View/Set SQL Editor Internal Variables and Their Values
Use "Truncate" To Delete All Rows of a Table
Use "Alter Table" To Change Table Definition
Adding Constraints to Table Definition
Specifying Primary Key in Table Definition

You can use the describe command on the following views to obtain information on your account.
View Name Description
DICT table names and table description
DICT_COLUMN column names of table names and column description
CAT names of all user's tables, views, synonyms, and sequences
OBJ information on all objects in your account
TABS table information on all user's tables
COLS column information on all user's columns
USER_VIEWS view information on all user's views
SYN synonyms information on all user's synonyms
SEQ sequence information on all user's sequences
USER_CONSTRAINTS constraint information on user's constraints
USER_CONS_COLUMNS column information on user's constraints
IND index information on all user's indices
USER_IND_COLUMNS column information on user's indices

2 comments:

pipsqueak said...

is this the same as 9 right? I thought DUAL is pretty consistent throughout the versions.

NabeelC said...

Yup... dual stays the same. 10g has some new features, but features from 9i remains same for backward compatibility.