Thirty-four databases
1. View database commands
2. Use a database
3. Check which library is currently in
4. View which tables are in the current database
5. Query the data in the table
6、 建库:create database testbase;
7、 建表:create table user(id int not null);
Create a table, the name is user_wangjing, the fields are id, date1, date2, etc.
Create a new table name, the parentheses mean int 11 bits, cannot be empty
8. Insert data: insert into user values(1);
9. View the information of the table:
10. Delete table
11. Delete the database: drop database testbase;
12. Create a new user:
create user 'student11'@'%' identified by "gloryroad";
FLUSH PRIVILEGES;
% means that all IPs can log in, 'student11'@'10.60.89.%' means that only IPs in this field can log in
13. Modify the password:
UPDATE USER SET PASSWORD=PASSWORD('12345622xw1') WHERE USER='gg1';
FLUSH PRIVILEGES;
14. Create users and modify user permissions
grant all privileges on test.user to student@"%" identified by "gloryroad" ; #Let the user have permission to operate any database
flush privileges;
15. Create a table and insert values
ENGINE=InnoDB storage database uses innoDB engine, if you want to use foreign keys, transactions and other functions, you need innodb engine
16. View the fields and attributes of the table: show columns from book_wangjing;
17. View index: SHOW INDEX FROM book_wangjing;
18. View 2 pieces of data, start from the beginning without reading the first two, print and then follow
19. View 3 after 2
20. Query table data and or:
21. Give an alias to the field in the table
22. Sorting of fields in the table
select * from book where book_author like '%老师';
Calculate the number of data in the table:
Calculate the average: