MySQL uses the underlying SQL statement (i)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.