************************************************************************
Example of Sequences in SQL:
Assume we have executed the following create table statement.
create table employees (
eno number(4) primary key,
ename varchar(30),
zip number(5),
hdate date);
Now we create a sequence object.
create sequence EnumberSeq start with 1000;
Now execute the following insert statements:
insert into employees values
(EnumberSeq.nextval, 'Tom Jones', 67226,'12-DEC-00');
Jones will be assigned a value of 1000 for column eno.
insert into employees values
(EnumberSeq.nextval, 'Ruth Brown',67226,'12-DEC-00');
Brown will be assigned a value of 1001 for column eno.
************************************************************************
Example of Dates in SQL:
Default format is 'DD-MON-YY"
where DD is 2 digit day of month
MON is 3 letter
abbreviation for month
YY is last 2 digits of
year
Other formats include
MM 2 digit
month
DY 3 letter
abbreviation for day
YYYY 4 digit year
Finding the current date:
Select sysdate from dual; dual is a
system defined dummy table with one column and one row.
The to_char function allows us to reformat a date
Select to_char(sysdate, 'DD-MON')
from dual;
************************************************************************
Execute a file containing SQL statements:
Create a file, for example, mysqlfile.sql (using your favorite editor) of SQL statements,
remember to terminate each statement with a semicolon
logon to Oracle and issue the following command at the sqlplus prompt with your file name:
sqlplus> start mysqlfile
this will execute every SQL statement in your file mysqlfile.sql
************************************************************************
Some useful tables that are part of the Oracle database catalog:
user_catalog contains
info about table name and table type
user_tab_columns contains information about the
columns in the tables
user_tables
contains much detailed information about the tables
user_views
contains information about views
************************************************************************