Library operations
Create a database: create database [database name];
Creating a character set of the database: create database [library name] CHARACTER SET = uft8;
The database created with parity: create database [library name] CHARACTER SET = uft8 COLLATE utf8_general_ci;
Show Database: show databases;
Delete the database: drop databases [library name];
Modify the database code: ALTER DATABASE [library name] set [coding];
Operating Table
(例 : id、name、sex)
create table [表名]
(
id int,
name varchar[99],
sex char[4],
)
Delete tables: drop table [table name]
increase:
insert into 【表名】(id,name,sex) values(1,'zhangsan','male');
delete:
Remove the table, "???" Data: delete from [table] where id = '???';
Delete all the data in the table: delete from [table name];
Use truncate delete records in the table: truncate table [table name];
check:
All information query: select id, name, sex from [table name];
Query specified id: select * from [table name] where id = "??";
90 is greater than the query: select * from [table] where id> 90;
Query greater than 90 less than 100 from [table] where id> 90 and id <100;
change:
Modify all the attribute value: update [table] set attribute =? ? ? ;
Modify specific properties: update [table] set attribute =? ? ? where name = specified;
Common MySQL command statement
Enter the mysql command line: mysql -uroot -p;
View all databases: show databases;
Create a database: create database niu charset utf8;
Delete the database: drop database niu;
Select the database: use databases;
View all the tables: show tables;
View create a database statement: show create database databasename;
View table creation statement: show create table tablename;
View table structure: desc tablenmae;
New field to the table: alter table [table]
[field name] [add properties]