Please send your Questions & Answers or Feedback to "mohan@javabook.org"

Explain about CREATE TABLE Statement ?

The SQL command for creating an empty table has the following form:

Syntax:

 

CREATE TABLE <table_name>

(

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

   . . . . . . . . .

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

  [<table constraint(s)>]

);

For each column, a name and a data type must be specified and the column name must be unique within the table definition.

Column definitions are separated by colons.

There is no difference between names in lower case letters and names in upper case letters. In fact, the only place where upper and lower case letters matter are strings comparisons.

A not null constraint is directly specified after the data type of the column and the constraint requires defined attribute values for that column, different from null. The keyword unique specifies that no two tuples can have the same attribute value for this column. Unless the condition not null is also speci_ed for this column, the attribute value null is allowed and two tuples having the attribute value null for this column do not violate the constraint.

 Example:

 

 CREATE TABLE Person

 (

   name VARCHAR(30),

   social-security-number number(10),

   age number,

   city VARCHAR(30),

   gender number(1),

   Birthdate DATE

);

Related Posts Plugin for WordPress, Blogger...
Flag Counter