Additions and deletions to establish the table Mysql- table change search

1. Create table statement:

CREATE TABLE table_name

(

field1  datatype,

field2  datatype,

field3  datatype

)

--field : Specifies the column name DataType : Specifies the column type

 

2. Check all the tables

show tables

 

3. Review the table structure

desc table

 

4. Delete the table:

drop table student

 

Table 5. Modify

sgender field representative

1) Adding fields

 

alter table student add column sgender varchar(2);

 

2) Delete field

alter table student drop column sgender

 

3) Modify Field Type

alter table student modify column remark varchar(100);

 

4) Modify field name

 alter table student change column sgender gender varchar(2);

 

5) Modify the table name

alter table student rename to teacher;

 

Guess you like

Origin www.cnblogs.com/sunlangui/p/11421961.html