Query database in the database name: show databases;
Creating a database: Create DB name;
Select a library: Use library name (for example: use PHP;)
View all tables in a database: show tables;
Delete a database: Drop the name of the library (drop database PHP;)
Create a simple table:
CREATE TABLE Class (
Stu Int,
Name varchar (20),
Age int,
Area varchar (20)
);
CREATE TABLE Score (
Stu Int,
Name varchar (20),
ke varchar (10),
Fen int
);
Modify table Name: Rename table original name to new table name; (Rename table score to NewsCore;) Note: Database name cannot be changed
Deletes a table: drop table name; (drop table newscore;)
Query a table for more information: DESC table name; (desc class;)
Declaration Character set: set names UTF8;
Insert information: INSERT into table name (Id,name,title) VALUES (NULL, ' asdasd ', ' Asdsad ');
Modify Information: Update table name set Name= ' Aza de Azad ' where id=1; Change your order by what?
Delete Information: Delete from table name where id=2; Press What to delete your own set
Add a column to a table (the added column defaults to the last column in the table): ALTER TABLE name add Add field name character type; (For example: Alter TABLE class add age2 tinyint unsigned; )
You can use after to declare where the new column is.
If the added column is placed on the first ALTER TABLE name add column declaration, boy add ID int primary KEY auto_increment
Added after a column: Alter TABLE boy add age tinyint unsigned not null default flower;
modifying columns
ALTER TABLE name change is a modified column names declaration;
ALTER TABLE boy change height smallint not null default 180;
Delete Column
ALTER TABLE name drop column name;
ALTER TABLE boy drop ID;
Create a table with the same structure as another table: create table g2 like goods;
Clear a table: Truncate G2;
Five seed sentences are ordered: Where,group,having,order By,limit in this order