cmd operation on MySQL

Source: Internet
Author: User

( 1 ) DDL

DDL: data definition Language.

Role:

Mainly used to define and maintain the database of various objects (such as libraries, tables, indexes, views, etc.), it can be said that the level of operation is in the database and the logical structure of the table and the storage structure , and does not have the actual data in the table to be added and censored!

The main operating keywords are:create,drop,alter

( 2 ) DML

DML:Data Manipulation Language, operation Language

Role:

The main is the record (data) in the table for the operation of the increase and deletion check!

the "Query" section, also known as DQL(data queryLanguage), is called the query language! (keyword Select)

( 3 ) DCL

DCL: Data Control Language language

Role:

The main is the unified management of the database and unified control of the language, such as: concurrency control, access control, security control, the specific operations are: database Rights Management, data backup and recovery, and so on!

Second: Operational database Enter the database:

1.mysql-u User name - p password

2.Mysql--default-character-set=latin1-u User name - p password

---- the MYSQL Client under Windows can insert Chinese and display Chinese is not garbled

three-step song:

Three steps for database operations:

Landing database

Use database name (Implicit database --- my understanding is to enter this database)

Set names GBK, because the current client is using GBK encoding, so the server will pass the data to the client before the code is converted to GBK, the same, the client before passing the data to the server, The encoding will also be converted to the default encoding of the server itself!

Three: specific operation ( 1 ) operation of the database: adding and deleting changes

increase (add a database):Create

Crete Database name

1. Deleting (Deleting a database)drop

Drop Database name

2. Change (Modify the database)alter

ALTER DATABASE library name new library options Information

Modify database options Information The character set is GBK, its default is UTF8;

In fact, the database modification should be the database name, database option information modification, but it is important that the name of the database is not modifiable, so what we can do is a database option information modification.

1. Check (1. see which databases are available) Show

View Databases -- see which databases are available

show databases;

(2) View database creation information

Show Create database name

( 2 The operation of the data table: Adding and deleting changes

1. increase (add a data table):Create

Crete table Datasheet name

2. deleting (Deleting a data table)drop

drop table data table name

( because when we delete a nonexistent data table, MySQL will error, then we add an if exists , first determine if there is a data table, if there is deleted, does not exist and will not error )

3 Modification (modification of the data table)alter

1 Modify table name rename to.

ALTER TABLE name Rename to new table name or modify more than one rename table old table name 1 to new table name 1 , old table name 2 to new table name 2;

2 Modify table options (character set and storage engine)

ALTER DATABASE table name new table option information

3. Modifying the column definition

4 Check (1. See what data tables are available) Show

View Data Sheets -- See what data tables are available

Show tables;

(2) View data sheet creation information

Show CREATE table data table name

Summary: For the database and data table operations are in fact a structure of an operation, and does not have the actual data in the table to be added and censored! So their operating keywords are generally:create,drop,alter

(2) Modifying data information (DML operations)

1. add:INSERT INTO

INSERT into table name ( field List ) VALUES ( List of values );

2. Delete Delete from

Delete from table name [ Delete condition ];

2. Check Select

Select *| Field List from Table name [ query conditions ];

change update set

Update table name set field 1= New value 1, field 2= new value 2 ... [ Modify Conditions ]

Summary: Simple database operations, first you want to determine the database object you want to manipulate, and then select the database (into the database), to determine whether you want to manipulate the table or data, with the The DDL language or the DML language, just a few more exercises!

cmd operation on MySQL

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.