Querying existing databases: show databases;
Operations on the database:
1. Delete database: Run drop database + name;
2. Add Database: Run CREATE DATABASE + name;
Operations on a table:
First you have to open the database of the table you want to manipulate before you can operate, run the Use+ database name
Querying tables in the database: Run show tables;
1. Add Table: Create TABLE + table name (ID int,name varchar (20));
When querying the table again, one more table was added successfully
2. Delete tables: Drop table O
When you query the table again, you can find that an OS table is missing, indicating that the deletion was successful.
Operations on data in a table
1, query the contents of the table: SELECT * from student;
2. Delete the contents of the table: Delete from table name where condition (note: Be careful when performing this step to ensure that "from deletion to escape" does not occur)
2, add the contents of the table: divided into 3 kinds
(1) Single: Insert into student (user_name, sex, birthday) values (' Little red ', ' male ', ' 2001-09-18 ');
(2) Multiple: Insert into student (user_name, sex, birthday) VALUES (' xiaoming ', ' Male ', ' 2001-09-18 '), (' xiaoming ', ' Male ', ' 2001-09-18 '), (' xiaoming ', ' Male ') , ' 2001-09-18 ');
(3) Insert query result: INSERT into student (user_name,sex,birthday) (select User_name,sex,birthday from student where id=10);
MySQL basic commands