Monday, August 16, 2010

Oracle 11g: Create Tables

Naming Rules
  • MUST begin with a Character
  • Length : 1-30 characters long
  • Can only contains:  A-Z, a-z, $,_,#,0-9
  • CANNOT be duplicate
  • CANNOT be oracle reserved words.
Must Have
  • CREATE TABLE privilege
  • a storage area.
If referring to other User's table, please use Users as prefix before table name: 
Select * from userA.employees

===>  SQL Queries:  Creating New Table & Use DEFAULT
create table dept
(
  deptno number(2),
  dname varchar2(14),
  loc  varchar2(13),
  create_date DATE default sysdate
);

describe dept;

Results

create table succeeded.

describe dept;
Name                           Null     Type                                                   
------------------------------ -------- ---------------
DEPTNO                                NUMBER(2)               
DNAME                                 VARCHAR2(14)          
LOC                                       VARCHAR2(13)                                                      
CREATE_DATE                    DATE                                           

No comments: