MySQL common SQL commands
Import
Mysql-uroot-proot test <c: \ test. SQL
Export
Mysqldump-uroot-proot test> C: \ test. SQL
Mysqldump-uroot-proot-r test> C: \ All. SQL-r stored procedure
Create a database
Create Database test;
Show Database
Show databases;
Use Database
Use test;
Show table names in the database
Show tables;
Create a table
Create Table D (ID int (10) Not null primary key auto_increment, username varchar (20 ));
Delete table
Drop table article;
Add data
Insert into article (article_type, article_content, article_title) values ('1', '2', '3 ');
Modify
Update article set article_content = '5' where article_id = 3;
Query
Select * from article where article_id = 3;
Delete table data
Delete from article where article_id = 3;
Delete Database
Drop database test;
######################################## ###############
MySQL Problems
MySQL garbled
MySQL DATA too long
/Usr/local/MySQL/bin/mysqldump-uroot-p $ PWD-r-B -- tables -- default-character-set = GBK test> D: \ A. SQL
-R can dump stored procedures
Zookeeper -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Script
Show database instances
Show databases;
Create database instance j1116
Create Database j1116;
Delete database instance j1116
Drop database j1116;
Create a table in a database instance
Use the database j1116;
Show tables in the database instance;
Create Table tab_student (ID int not null primary key auto_increment, name varchar (32), sex varchar (2), age int, XH varchar (10 ));
Display table structure
Desc tab_student;
Insert data
Insert into tab_student (name, sex, age, XH) values ('zhang san', 'female ', 23, '123 ');
Query statement
Select * From tab_student; query all fields in the table
Select name from tab_student; only query the name field
Select name from tab_student where age = 23; query the names of students whose ages are 23
Delete statement
Delete from tab_student; Delete full table data
Delete from tab_student where age <24; Delete students younger than 24 years old
Update statement
Update tab_student set sex = 'nv ', age = 21 where id = 7; update the gender and age of students whose ID is 7.
Delete table
Drop table tab_student;