Use dB;
-- List all tables in the current database
Show tables;
Show tables like's % ';
Create Table Name
(
Column name type modification constraints,
Sid int (3) unsigned zerofill primary key auto_increment
Sgender Enum ('male', 'female ', 'confidential') default 'male'
) Engine = MyISAM default charset = utf8;
-- Create a table
Create Table if not exists s
(
Sid int (3) unsigned zerofill primary key auto_increment,
Sname varchar (5) not null,
Sgender Enum ('male', 'female ', 'confidential') default 'male'
) Engine = MyISAM default charset = utf8;
-- Quickly copy the table structure and create a new table
Create Table if not exists YY like student;
Create Table if not exists XX select * from student;
Select * from student;
Select * from YY;
Insert into XX select * from XX;
Insert into student select * from student;
Select * from XX;
Desc YY;
Insert into S values (30, 'zhang san', 'A ');
Insert into S (sname) values ('Li Yong ');
Desc S;
Select * from s where sgender = '';
-- Delete a table
Drop table if exists st;
-- Delete a batch of tables
Drop table if exists's ', 'XX', 'cc ';
-- Modify the table name
Rename table student to bbs_student;
Alter table bbs_student rename student;
Alter table bbs_student Rename to student;
-- Modify the column name and Data Type
Alter table student change Sid SnO int unsigned;
-- Delete the primary key of a table
Alter table student drop primary key;
-- Add a primary key to a table
Alter table student add constraint PK primary key (SNO );
Desc student;
-- Add a column at the end of the table
Alter table student add column sscore tinyint unsigned;
Alter table student add column sscore tinyint unsigned first;
Alter table student add column sscore tinyint unsigned after sname;
-- Delete a column
Alter table student drop column sscore;
-- View table structure
Desc student;
Table operations-Create Table-delete table-Modify Table Name-Modify column name and data type-delete/Add primary key-Add a column at the end of the table-View table structure