There are 3 types of SQL languages:
1 DDL Statement Database definition statement: Database, table, view, index, stored procedure, such as Create DROP ALTER
2 DML Statement Database manipulation language: Insert Delete update query data, insert Delete, update SELECT
3 DCL Statement Database Control Language: for example, to control the access rights of a user grant REMOVE
Action folder (Library):
Increase
Create Database db1 charset UTF8;
Check
Show CREATE Database db1; #查看刚新建的数据库
show databases;
Select Database (); #查看当前库
Change
ALTER DATABASE DB1 CharSet GBK;
By deleting
Drop database db1;
Database type:
INFORMATION_SCHEMA: Virtual library, do not occupy disk space, storage is the database startup parameters, such as user table information, column information, permission information, character information, etc.
Performance_schema:mysql 5.5 begins a new database that collects database server performance parameters, records various events that occur when processing query requests,
Locks and other phenomena
MySQL: Authorization library, access information for primary storage system users
Test:mysql Database System Auto-created test database
Action file (table)
Increase
Use DB1; # switch Libraries
Select Database (); # View your current folder
CREATE TABLE t1 (id int, name char);
CREATE TABLE t2 Select Id,name from T1 # Copy table
Check
Show Create table1;
Show tables;
Desc T1;
Change
ALTER TABLE T1 modify name char (6);
ALTER TABLE t1 change name name char (7);
By deleting
drop table T1;
Manipulate file contents (record)
Increase
Insert T1 (Id,name) VALUES (1, ' Egon1 '), (2, ' egon2 ');
Check
Select Id,name from Db1.t1;
SELECT * from Db1.t1\g; # when the \g record is more, the line break shows
Change
Update db1.t1 set name= ' SB ' where id=2;
By deleting
Delete from T1 where id=2;
Basic SQL statements