Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
7_SQLDDL

7_SQLDDL

Ratings: (0)|Views: 27|Likes:
Published by api-3827483

More info:

Published by: api-3827483 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as RTF, PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

sql \u2013 ddl (data definition
language)
ddl
ddl
objectives :
objectives :
\u2013list the types of ddl commands
\u2013state & demonstrate the use of create table
command
\u2013list & define the integrity constraints
swhat is ddl?
\u2013data definition language is a set of commands used to
create, modify or drop various database objects such as
tables, views, synonyms etc.
ddl commands
screate
\u2013creating database objects
salter
\u2013modifying database object\u2019s definition/structure
sdrop
\u2013removing/deleting database objects
creating database tables
stables are created using the create table command
\u2013tables are owned by the user who creates them
\u2013the names of all the tables owned by a given user must
be unique
\u2013the column name must be specified with their data types
ssyntax :
create table <table_name>
(<column_name> <datatype (size)>

[default<expr>]
[constraint <constraint_name>]
[<column_constraint>]
[ enable / disable],
\u2026\u2026..
[constraint <constraint_name>]
[<table_constraint>]
[ enable / disable],

\u2026\u2026\u2026\u2026
);
naming rules
snaming rules for oracle database objects :
\u2013the name must begin with an alphabet
\u2013names may contain letters, numerals, special characters
like _ (underscore),
$ (dollar), # (hash)

\u2013maximum length is 30 characters
\u2013names are not case sensitive
\u2013the name must not be duplicate of another object created

by you
\u2013the name can not be a sql reserved word
integrity constraints
swhile creating a table, constraints can be specified
sintegrity constraints help you enforce business rules
on data in your database
ssql rejects any value that violets the constraint
stypes of constraints
\u2013column constraints
scolumns constraints apply to individual columns
\u2013table constraints
stable constraints apply to a group of one or more columns
sconstraints can be specified with create or alter
command
integrity constraints
sadvantages
\u2013do not have to program your application to check for the
validity of data
\u2013the integrity constraints for a table are global to all
programs/users using it
\u2013easy to specify and maintain
\u2013when business rules change, constraints can be modified
centrally
constraints: null
sthis constraint is placed immediately after the column
definition
\u2013null
scolumn can contain null values
\u2013not null
scolumn can not contain null values
sexample :
create table emp
(empno number (4) not null, \u2026\u2026..);
constraints: unique
sunique constraint
\u2013ensures uniqueness of the values in a column(s)
sexample :
create table emp
(empno number (4) not null unique, \u2026\u2026..);

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->