DDL -Data Definition Language
Create,Alter,Drop statements.
To delete a column in a table, use the following syntax
(notice that some database systems dont allow deleting a column):
ALTER TABLE table_name DROP COLUMN column_name
Alter table employee drop column salary
To change the data type of a column in a table, use the following syntax:
ALTER TABLE table_name ALTER COLUMN column_name datatype
Alter table employee alter column salary money
Drop statement
The DROP TABLE statement is used to delete a table.
syntax:
DROP TABLE table_name
drop table employee
The DROP DATABASE statement is used to delete a database.
syntax:
DROP DATABASE database_name
drop database siva
Create,Alter,Drop statements.
Create statement
The CREATE TABLE statement is used to create a table in a database.
syntax:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
....
....
)
create table employee(empno int,name varchar(30),desg char(3),salary int)
Alter statement
The ALTER TABLE statement is used to add, delete, or modify columns
in an existing table.
To add a column in a table, use the following syntax:
ALTER TABLE table_name ADD column_name datatype
Alter table employee add deptno int 'Adding a new field to the table'
syntax:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
....
....
)
create table employee(empno int,name varchar(30),desg char(3),salary int)
Alter statement
The ALTER TABLE statement is used to add, delete, or modify columns
in an existing table.
To add a column in a table, use the following syntax:
ALTER TABLE table_name ADD column_name datatype
Alter table employee add deptno int 'Adding a new field to the table'
To delete a column in a table, use the following syntax
(notice that some database systems dont allow deleting a column):
ALTER TABLE table_name DROP COLUMN column_name
Alter table employee drop column salary
To change the data type of a column in a table, use the following syntax:
ALTER TABLE table_name ALTER COLUMN column_name datatype
Alter table employee alter column salary money
Drop statement
The DROP TABLE statement is used to delete a table.
syntax:
DROP TABLE table_name
drop table employee
The DROP DATABASE statement is used to delete a database.
syntax:
DROP DATABASE database_name
drop database siva
0 comments:
Post a Comment