MySQL Common commands

Source: Internet
Author: User

Common commands

1. Displays the list of databases in the current database server:

    MySQL> SHOW DATABASES;

2. Establish the database:

    MySQL>CREATEdatabase name;

3. Set up the data sheet:

MySQL> use library name; MySQL>CREATETABLEVARCHAR(1CHAR);

4. Delete the database:

    MySQL>DROPdatabase name;

5. Delete Data sheet:

    MySQL>DROP table name;

6. Empty the records in the table:

MySQL>DELETE from table name; (This command represents the emptying of the table data)
TRUNCATE table name; (This command represents the emptying of the table data and initializing the table)

7. Insert a record into the table:

    MySQL>INSERTintoVALUES ("HyQ", "M");

8. Update the data in the table:

    MySQL-UPDATESET field name 1='a', field name 2='  b'WHERE field Name 3='C';

9. Load data into the data table in text mode:

MySQL>LOAD DATA LOCAL INFILE "D:/ into table table name;

10. Import the. sql File command:

MySQL> use database name; MySQL> SOURCE d:/mysql.sql;

11, the command line to modify the root password:

MySQL>UPDATE MySQL. User SET Password=password (' new password 'WHEREUser= ' Root '  ; MySQL>privileges;

The above are all regular, and below are some of the available

  

In-table plus fields

Alter TableTable nameAddField nameint  not NULL default 'Default Value'Comment'Notes'After field name; Alter TableProjectAddTypetinyint  not NULL default 2Comment'default is 2,2 for normal business, 3 for business card'

In-table modified fields

Alter Table column varchar (" home Address ";

Add index

    Alter Table Add Index Lname_fname (Lname,fname); (federated index)     Alter Table Add index fname (fname); (Single-column index)

  

MySQL Common commands

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.