Friday, September 11, 2009

Oracle/SQL

Data Definition in SQL

Creating Tables

The SQL command for creating table is

create table <table>

(

<column 1> <data type> [not null] [unique] [<column constraint>],

. . . . . . . . .

<column n> <data type> [not null] [unique] [<column constraint>],

[<table constraint(s)>]

);

Each column must have a name and data type. Column name must be unique within the table definition. The column definition must be separated by comma. Column names are not case sensitive. ‘Not null’ constraint is directly specified after the data type of the column. The constraint requires defined attribute values for that column, different from null.

Eg: The create table statement for our EMP table has the form

create table EMP

(

emp_code number(5) not null,

emp_name varchar2(30) not null,

father_name varchar2(10),

Join_date date,

Basic_pay number(7,2),

Department_no number(2)

);

Remark: Except for the columns emp_code and emp_name null values are allowed.

No comments:

Post a Comment

Ads

Your Ad Here