SQL composition
SQL full name is Structured Query language, according to the function, the SQL language mainly consists of the following parts.
- dml--data manipulation language used to insert, modify, and delete data in a database.
- ddl--The data definition language, establishes the database, database objects, and defines its columns.
- dql--data Query Language, query the data in the database
- dcl--Data Control Language, control database component access permission, access permissions, etc. such as Grant, REVOKE.
Common commands in MySQL
MySQL query is case insensitive by default
DOS Boot service:
net start MySQL start MySQL service
net stop MySQL stop MySQL service
Command line Login:
Mysql–u Root–p (you will be prompted to enter the password)
PS: If you are connecting to another machine, you need to add a parameter:-H machine IP
Basic operation:
Status Displays the current running status of the MySQL service
Select version (); Show current MySQL version
Select Current_date; Show current date (case-sensitive)
Select Now (); Displays the current date, time
Select Database (); Displays the database currently in use
Library operation (Action statement to; end):
show databases; Show all databases
Create DATABASE <database name>; Create a database
Drop database <database name> directly deletes the databases without alerting
MySQL admin drop <database name> before deleting the database, there are hints
Use <database name>; Open Database
Show tables; Show all tables in the database
Table Operation:
CREATE TABLE <table name>
(Field 1 data type, field 2 data type); Build table
drop table <table name>; Delete a table
Describe <table name>; Structure of the Display table
Desc <table name>; Structure of the Display table
SELECT * FROM <table name> display the contents of the table
Delete from <table name>; Clear the contents of the table
Introduction to MySQL SQL and basic commands