MySQL basic (DDL)
SQL Classification
SQL statements can be divided into three categories.
DDL: Data Definition Language, defining data segments, databases, data tables, and other DML: data manipulation statements, used to add, delete, update, and query database records DCL: Data Control statements, statements used to control the direct permission and access level of different data segments
Prepare, first start MySQL Service net start mysql, and enter mysql, mysql-u root-p (-u is followed by the database user,-p indicates that the password needs to be entered)
1. DDL statements
Language used to create, delete, and modify objects in the database.
1.1 create database ----;
After creating the database, view the database show databases;
Select the database use ---
View the table show tables in the database;
1.2 delete a database
Drop database ----;
1.3 create a table
Create table --- (name1 type constraint, name2 type constraint ......);
Check the created table to see if it meets the requirements of desc --;
1.4 delete a table
Drop table ----;
1.5 modify a table
Alter table --- modify ---;
Add the new field alter table --- add colum ----;
Delete field alter table --- drop colum ---;
Alter table --- change ---;