The command line input mysql-u root-p, enter the password again, enters MySQL.
The terminal command ends with a semicolon as a statement, and can be divided into multiple lines of input, with only a semicolon at the end. Such as:
I.DDL: Data definition language Language
Role: Defines a database or table structure.
object to manipulate: the structure of a database or table.
Keyword: CREATE ALTER DROP
① Querying the database:
the display currently has several libraries, input: mysql>show DATABASES;
② Create a database:
Create a database called MYDB1: mysql>CREATE DATABASE mydb1;
View Database creation details:mysql>show Create database mydb1;
Create a MYDB2 database that uses the GBK character set: mysql>create db mydb2 CHARACTER SET GBK;
Create a MYDB3 database that uses the GBK character set with proofing rules: mysql>create db mydb3 CHARACTER SET GBK COLLATE gbk_chinese_ci;
③ Deleting a database:
Delete the previously created MYDB3 database: mysql>DROP db mydb3;
for the operation of a database, assume that the database is test:
The first thing to choose is the database: mysql> use test;
① Display the table information:
Show all tables in the current database: mysql>show TABLES;
to view the definition of a table structure: Mysql>desc employee;
View the table's creation details: mysql>SHOW create table user;
② Create a table:
Create a table of employees:
Mysql>CREATE TABLEEmployee (IDint, namevarchar( $), Gendervarchar(Ten), Birthday date, entry_date date, Jobvarchar( $), Salaryfloat(8,2), Resumetext);
③ Modify the table:
An image column is basically added to the employee table above : MySQL>ALTER table employee ADD image blob;
View the definition of a table structure: mysql>DESC employee;
Modify the job column to a length of: mysql>ALTER TABLE employee MODIFY job varchar(60 );
Delete image column: mysql>ALTER TABLE employee DROP image;
Table name changed to User: mysql>RENAME table employee to user;
Modify the table's character set to GBK: mysql>ALTER table user CHARACTER set GBK;
Column Name name modified to username: mysql>ALTER TABLE user change name username varchar (a);
④ Delete Table:
Delete Table Employee: drop table employee;
MySQL uses the underlying SQL statement (i)