"MySQL" MySQL database operation command Daquan

Source: Internet
Author: User

Special NOTE: MySQL database is not case-sensitive

1, create the database: creating databasesThinkgamer;

2. Delete databases:drop database thinkgamer;

3, select a database: Usethinkgamer;

4. Create a data table:

Mysql>create Table Cyan

(
-ID INT (3) NOT null primary key,

Name char (3);

--Sex char (1) NOT NULL default 1
) engine = InnoDB;

Enter, not null set the field cannot be empty, primary key is set primary key, default name is 1.

5. Delete tables:drop table cyan;

6. Add columns to the table:ALTER TABLE cyan Add hobby char (a);

7, display the relevant information of the table:describe cyan;

8, display a column of information:Select school number from cyan;

9, add informationto the table: Insert Cyan VALUES ("111", "Thinkgamer", "female", "Dance");

10. Modify a table for a row of information:

Mysql>update Cyan
->set sex = "male", hobby = "Badminton"

->where No. = 111;

You can enter.

1 . Modify some information for multiple tables:

Mysql>update table_name1,table_name2
->set table_name1. Sex = "male", table_name2. Sex = "female"

->where table_name1.id = table_name2.id;

You can enter.

12. Delete a line: Delete fromcyan where study number =111;

13. Delete the gender-female:Delete from cyan where sex = female;

14. Delete multiple rows from multiple tables:

Mysql>delete Table1,table2

->from Table1,table2,table3

->where Table1.id=table2.id and Table2.id=table3.id;

You can enter.

15, clear the table data:truncate TABLE cyan;

Note: Once the data is cleared, it cannot be recovered.

Other:

Select User (); displays the current user.

SELECT @ @version; Displays the database version.

Show cyan status; Displays the status of the currently used table

Show character set; Display the character set supported by the database

Show variables like '%char% ' viewing the default character set

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"MySQL" MySQL database operation command Daquan

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.