DDL on Table


education ddl sql server
after creating a database , to store data in the database would have to make
table that serves as a container for the data , in making a table of course we must
using DDL commands as commands to create , modify , and delete objects
The following is the syntax structure DDL used to create a table :
CREATE TABLE [ Table Name ]
(

)

to determine the field that we will create , in parentheses we isikian field names and
data type . example :
CREATE TABLE [ Table Name ]
(
 field1 char ( 5 ) ,
 field2 varchar ( 10 ) ,
 field3 int
)

in making a table we must define a unique field , to mark the primary key . example :
CREATE TABLE [ Table Name ]
(
 field1 char ( 5 ) primary key ,
 field2 varchar ( 10 ) ,
 field3 int
)

sample making tables to keep user data
CREATE TABLE t_user
(
 userID varchar ( 10 ) primary key ,
 name varchar ( 20 ) ,
)

The following is the syntax structure DDL used to alter a table :
ALTER TABLE [ Table Name ] statement

example in the use of alter table :
ALTER TABLE ADD COLUMNS t_user int age

DDL syntax to remove the last table :
DROP TABLE [ Table Name ]

example of use :
DROP TABLE t_user

Comments