Basic commands in MySQL

Source: Internet
Author: User

1. Use the show statement to find out the current database on the server: mysql> show databases;

2. Create a database mysqldata: mysql> Create Database mysqldata;

3. Go to the table: mysql> Use *** (your table name );

4. create a table: mysql> Create Table text (**, **, **); (text is also the name of your table) for example: mysql> Create Table text (ID int, name varchar (20 ));

5. Add a record to the table: mysql> insert into text (ID, name) values (1, 'night ');

6. view the information in the table: mysql> select * from text; (* indicates to view all the information in the table. To view only one of the information, you can write: Select name from text where id = 1 );

7. delete a database: mysql> drop table mytable;

8. auto-increment table IDs: mysql> Create Table text (ID int auto_increment, primary key (ID), name varchar (10); (if you want to have a maximum id value, it should be written as follows: mysql> Create Table text (ID int (20) not null auto_increment, primary key (ID), name varchar (10 ));)

9. Change the table information: mysql> Update mytable Set ID = 6 where name = 'dark ';

10. In the sorting of MySQL rows: Select * from table name order by name (you can specify the order in which to view it );

11. MySQL sorting in columns: alter table table name Modify Field Name field name type after field example: alter table user_info modify user_name varchar (10) after user_id;

12. How to directly access MySQL from the command line: Enter Net start mysqlmysql-u root-P in the command line


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: 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.