Home >Database >Mysql Tutorial >sql creates tables, modifies table structures, and deletes tables

sql creates tables, modifies table structures, and deletes tables

伊谢尔伦
伊谢尔伦Original
2016-12-03 10:49:001602browse

1. Create a database table

--Which database to use, if you don’t write this sentence, it is the default database, you can also use the mouse to select the current database

use testDB

--Create table

Create Table tablename

(

                                                                                                                                                                                           .

id int primary key not null identity(1,1),

--unique name varchar(20) not null unique

)

2. Delete table

Drop table table name

3. Modify the table structure

--Add column

Alter table table name

Add column name type

--Delete column

Alter table table name

drop cloumn column name

--Modify column, modify column Type

Alter table table name

Alter column column name type

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn