The SQL DDL statements

1.CREATE DATABASE statement
CREATE DATABASE to create a database.

CREATE DATABASE database_name

2.CREATE TABLE statement
CREATE TABLE statement to create a table in the database.

CREATE TABLE 表名称(列名称1 数据类型,列名称2 数据类型,列名称3 数据类型,....)

Data types are as follows:
Here Insert Picture Description

eg:CREATE TABLE Persons(Id_P int,LastName varchar(255),FirstName varchar(255),Address varchar(255),City varchar(255))

3. ALTER TABLE statement
ALTER TABLE statement is used to add an existing table, modify, or delete columns.
To add columns in a table, use the following syntax:

ALTER TABLE table_name ADD column_name datatype

To delete a column in a table, use the following syntax :( Note: Some database systems do not allow this deletion method (DROP COLUMN column_name) columns in a database table).

ALTER TABLE table_name DROP COLUMN column_name

To change the data type of columns in the table, use the following syntax:

ALTER TABLE table_name ALTER COLUMN column_name datatype

example:

eg:ALTER TABLE Persons ADD Birthday date           //添加
eg:ALTER TABLE Persons ALTER COLUMN Birthday year           //修改
eg:ALTER TABLE Person DROP COLUMN Birthday           //删除
Published 24 original articles · won praise 13 · views 4951

Guess you like

Origin blog.csdn.net/qq_34423913/article/details/104313865