Friday, October 26, 2007

Oracle PL/SQL

More Oracle/PLSQL Topics on Tech on the net

Login to
SQL*Plus:
sqlplus username/password

Finding the objects in the database:
select owner, object_name , object_type from dba_objects where object_name like 'cust%'; 

Finding the structure of a table:
desc customers;

Creating Tables in Default tablespace:
create table customers
(
CUST_ID NUMBER(5) NOT NULL,
CUST_NAME VARCHAR2(20) NOT NULL,
CUST_DATE Date NULL
);

DUAL table: A standard Oracle database table named DUAL, which contains exactly one row.
select abs(-1) from dual;

Using Sequences:
create sequence student_id start with 1 increment by 1 cache 20 order;
select student_id.nextval from dual;

to see the contents of the database sequence
desc user_sequences;
select * from user_sequences;

To find out what default tablespace is assigned when our Oracle account was initially created:
select * from user_users;

Storage Characteristics of Tables
select * from user_tablespaces;

To_Date Function:converts a string to a date
to_date( string1, [ format_mask ], [ nls_language ] )
to_date('2003/07/09', 'yyyy/mm/dd')

No comments: