MySQL Common commands (in summary)

Source: Internet
Author: User
In Windows, when the MySQL service is started and disabled, netstopmysqlnetstartmysql (where mysql is the MySQL service name) displays all databases showdatabases, sets the current database usedatabasename, and displays the current database selectdatabase (); display the showtables table in the current database; common SQL commands

In Windows, the MySQL service starts and disables the net stop mysql net start mysql (where mysql is the MySQL service name). show databases is displayed for all databases. Set the current database use databasename; displays the current database select database (); displays the tables in the current database show tables; commonly used SQL commands

Start and close the MySQL service in Windows

Net stop mysql

Net start mysql

(Mysql is the MySQL service name)


Show all databases

Show databases;

Set the current database

Use databasename;

Show Current Database

Select database ();

Display tables in the current database

Show tables;


Common SQL commands:

(1) Data Record Filtering:
SQL = "select * from data table where field name = Field Value order by field name [desc]"
SQL = "select * from data table where field name like '% Field Value %' order by field name [desc]"
SQL = "select top 10 * from data table where field name order by field name [desc]"
SQL = "select * from data table where field name in ('value 1', 'value 2', 'value 3 ')"
SQL = "select * from data table where field name between value 1 and value 2"

(2) update data records:
SQL = "update data table set field name = field value where condition expression"
SQL = "update data table set field 1 = value 1, Field 2 = value 2 ...... Field n = value n where condition expression"

(3) Delete data records:
SQL = "delete from data table where condition expression"
SQL = "delete from data table" (delete all data table Records)

(4) add data records:
SQL = "insert into data table (Field 1, Field 2, Field 3 ...) Valuess (value 1, value 2, value 3 ...) "
SQL = "insert into target data table select * from source data table" (add records of source data table to target data table)

(5) Create and delete data tables:
Create table data TABLE name (Field 1 type 1 (length), Field 2 type 2 (length )...... )
Example: create table tab01 (name varchar (50), datetime default now ())
Drop table data TABLE name (permanently delete a data TABLE)

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.