MySQL Common command Summary

Source: Internet
Author: User

1. In the command line, type NET Start/stop mysql on/off MySQL service
2. Type the Mysql-u user name-p password in the command line to connect to the database

(The following command must be followed by a semicolon '; ') )
3. Use the show statement to show what database exists on the current server: show databases;

4. Create a database with the creation statement: The name of the Create library;

5. Use the USE statement to select the database to be used: Using Test;

6. Use the show statement to see which tables are available: show tables;

7. Create a database table

CREATE TABLE Person
(
Name varchar () is not NULL,
Password varchar () NOT NULL
);

8. Display the structure of the table: Describe table name

9. Add a record to the table: INSERT into table name values (' Value ',..., ' value ');

10. Update the data in the table: Update table name set column Header = ' value ';

11. Import the local file with load: Load data local infile ' file name ' into table table name;

The column and column values in the local file are separated by the "tab" key, and the rows and rows are separated by a carriage return character

12. Select data:

1) Select all data: SELECT * FROM table name

2) Select specific data: SELECT * FROM table name WHERE range (logical connection Word is and,or, etc.)

13. Add Column: Alter table tabname add column col type

The following example statement adds a PSD field to the table user.

mysql> ALTER TABLE user ADD COLUMN psd INT (10);

14. Delete Column: ALTER TABLE tablename drop ColumnName

The following example statement removes the PSD field from the table user.

mysql> ALTER TABLE user drop PSD;

15. Delete records:

DELETE from TableName [WHERE CONDITIONAL];

No where means delete all records in table

Procedure statements, see http://www.blogjava.net/kissjava/archive/2008/07/16/215177.html,

MySQL Common command Summary

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.