MySQL Database common commands

Source: Internet
Author: User

MySQL Connection

- - penter Password: ******

The mysql> Command Prompt window will appear after successful login

 to The MySQL monitor....mysql >

Create a database after logging in

CREATE DATABASE  IF  not EXISTS DatabaseName;

Deleting a database

DROP DatabaseName;

Select Database

 Use DatabaseName;

Create a data table

CREATE TABLE table_name (column_name column_type);

Create a data table example

CREATE TABLE IF  not EXISTS' test_tbl ' (' test_id ' )INTUNSIGNED auto_increment, ' Test_title 'VARCHAR( -) not NULL, ' Test_author 'VARCHAR( +) not NULL, ' submission_date ' date,PRIMARY KEY(' test_id ')) ENGINE=InnoDBDEFAULTCHARSET=UTF8;

Delete a data table

DROP TABLE table_name;

Inserting data

INSERT  into table_name (field1, Field2,... fieldn)                        VALUES                        (value1, value2,... valuen);

Querying data

SELECT Column_name,column_name  from table_name [WHERE Clause] [[LIMIT N]

Using the WHERE clause

SELECT  from table_name1, table_name2 ... [WHERE condition1 [and [OR]] condition2 .....

Example of reading data

SELECT *  from WHERE Test_author='youngng';

Example of exporting data in SQL format

- - > Dump ******

Import SQL File data

MySQL>source Sqlfilepath;

MySQL Database common commands

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.