Introduction to MySQL SQL and basic commands

Source: Internet
Author: User
Tags mysql query mysql version

SQL composition

SQL full name is Structured Query language, according to the function, the SQL language mainly consists of the following parts.

    • dml--data manipulation language used to insert, modify, and delete data in a database.
    • ddl--The data definition language, establishes the database, database objects, and defines its columns.
    • dql--data Query Language, query the data in the database
    • dcl--Data Control Language, control database component access permission, access permissions, etc. such as Grant, REVOKE.

Common commands in MySQL

MySQL query is case insensitive by default

DOS Boot service:

net start MySQL start MySQL service

net stop MySQL stop MySQL service

Command line Login:

Mysql–u Root–p (you will be prompted to enter the password)

PS: If you are connecting to another machine, you need to add a parameter:-H machine IP

Basic operation:

Status Displays the current running status of the MySQL service

Select version (); Show current MySQL version

Select Current_date; Show current date (case-sensitive)

Select Now (); Displays the current date, time

Select Database (); Displays the database currently in use

Library operation (Action statement to; end):

show databases; Show all databases

Create DATABASE <database name>; Create a database

Drop database <database name> directly deletes the databases without alerting

MySQL admin drop <database name> before deleting the database, there are hints

Use <database name>; Open Database

Show tables; Show all tables in the database

Table Operation:

CREATE TABLE <table name>

(Field 1 data type, field 2 data type); Build table

drop table <table name>; Delete a table

Describe <table name>; Structure of the Display table

Desc <table name>; Structure of the Display table

SELECT * FROM <table name> display the contents of the table

Delete from <table name>; Clear the contents of the table

Introduction to MySQL SQL and basic 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.