1. Open the database, the user name is root, the password is 123456
mysql -uroot -p123456
2. Create a library, the meaning of this statement is to create if the test library does not exist, CHARSET utf8 COLLATE utf8_general_ci is case-insensitive insert data
CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
3. Create a database directly
create database test;
4. Show existing libraries
show databases;
5. Delete the library
drop database test;
6. Use test library
use test;
7. Show existing tables
show tables;
8. Show which library is currently in use
select database();
9. View the table
creation statement show creat table students of the specified table ;
10. Check whether the table has default submission
show variables like'autocommit';
11. Add index to the table
ALTER TABLE'student' ADD INDEX stu_id_index ('name');
12.新建表
create table students(id int not null,
student_id varchar(20) not null,
name varchar(30) not null,
sex char(4))
13. Insert data
into students values (1001,2001,'Xiao Ming','male')