Note: MySQL database is a very lightweight database management system, compared to large-scale database management system such as oracle,mysql more lightweight, flexible, fast development features, more suitable for small and medium-sized data storage and architecture. This is why MySQL can be used by tens of thousands of websites. Advanced applications such as cursors, triggers, transactions, and stored procedures have been supported since the 5 release, adding important weights to MySQL's ease-of-use and enterprise service development. Database is very basic, but the performance of the database optimization is the most important, so much optimization, it will be beneficial.
0. User Management
1.
I. Database operations
1. View the database
SHOW DATABASES;
2. Create a database
CREATE DATABASE db_name; #db_name为表名
3. Using the Database
Use db_name;
4. Deleting a database
DROP DATABASE db_name;
Two. Create a table
1. Create a table
CREATE TABLE table_name ( ID TINYINT UNSIGNED not NULL auto_increment, Char () not null ,int is not null, PRIMARY KEY (ID ) #设置主键) ENGINE=innodb;
2. Copying a table
CREATE TABLE tb_name2 SELECT * from Tb_name;
3. Create a temporary table
# (This is the same as creating a normal table)
4. View the tables available in the database
SHOW TABLES;
5. View the structure of the table
DESCRIBE Tb_name;
6. Delete a table
DROP TABLE Tb_name;
7. Table renaming
RENAME TABLE name_old to Name_new;
Three. Modify the table
ADD COLUMN address varchar (theDROP Change score score SMALLINT (4) is not NULL;
Four. Inserting data
1. Inserting data
INSERT into tb_name (ID, name,score) VALUES (null,' Zhang San ',+), (null,' Zhang Si ',178), (NULL,' Zhang five ',134);
2. Inserting the retrieved data
INSERT into Tb_name (name,score) SELECT name,score from Tb_name2;
Five. Updating data
UPDATE tb_name SET score=189id=2; UPDATE tablename SET columnName=newvalue [WHERE condition]
Three. Filtering with wildcards
' jet% ' #% matches any character that occurs any number of times
' _ Jet '; #_ match one character
MySQL Database common operation collation