创建表
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type
);
CREATE TABLE Persons
(
Id_P int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
删除表
DROP TABLE table_name;
DROP TABLE Person;
更改表
ALTER TABLE语句用于在已有的表中增加,删除,更改列。
增加列
ALTER TABLE table_name ADD column_name data_type;
ALTER TABLE Person ADD Age int;
ALTER TABLE Person ADD Name varchar(128);
删除列
ALTER TABLE table_name DROP COLUMN column_name;
ALTER TABLE Person DROP COLUMN Age;
ALTER TABLE Person DROP COLUMN Name;
更改列
ALTER TABLE table_name ALTER COLUMN column_name data_type;
ALTER TABLE Person ALTER COLUMN ID varchar(16);
ALTER TABLE Person ALTER COLUMN Name varchar(56);