Matt's SQL Reference

index

Data Definition Language (DDL) Statements

CommandObjectSyntaxExample
Create Create Table create table tablename
(row1 datatype, row2 datatype);
create table customers (
cust_id number(12,0) primary key not null,
last_name varchar2(30),
first_name varchar2(30),
age number(3,0));
create table table
as select columns
from table2;
create table customers as select * from oldcustomers;
Create View create view viewname
as select columns
from tables
where conditions;
create view names as select last_name, first_name from customers;
create or replace view viewname as select columns from tables; create or replace view names as select last_name, first_name from customers;
Create Index create [unique] index indexname
on tablename(columnname);
create index lastname on customers(last_name);
create unique index ssn on customers(social_security_no);
Create Synonym create [public] synonym synonymname for tablename; create public synonym billcust for sys.fiscally_billed_customers;
Create Role create role role; create role admins;
Alter Alter Table Alter Index
Drop Drop Table drop table table; drop table customers;
Grant grant (select,update,insert,delete)
on table
to (user, role, or PUBLIC);
grant select on * to public;
grant select,update on customers,addresses to dataentry;
grant select, update, insert, delete on * to admin,bjones;

Last updated Please report any problems or comments to matt@mindflip.com