MySQL Basic operation

Source: Internet
Author: User

    • Database operations

Create a database

Create Database character Set UTF8

Deleting a database

Drop  Database name
    • Table Operations

CREATE TABLE: (Auto_increment, unique unique)

--Create a new table Create TableT_user (IDbigint Primary Keyauto_increment, usernamevarchar( -)Unique, namevarchar( -), Passwordvarchar( -), Sexvarchar(1) );--Create a new table based on an existing tableCreate TableTab_new likeTab_old

Table itself operation

-- Table Renaming Alter Table Table name rename new table name -- Delete a table Drop  Table Name

Other operations of the table

--Add primary KeyAlter TableTabNameAdd Primary Key(COL)--Delete primary KeyAlter TableTabNameDrop Primary Key(COL)--Create an indexCreate [Unique] IndexIdxname ontabname (col ....)--Delete IndexDrop IndexIdxname--Create a ViewCreate ViewViewName as SelectStatement--Delete a viewDrop ViewViewName

Table Chizang, Delete, change

--AddAlter TableTable1AddIdint  not NullAuto_incrementPrimary Key--Modify a field typeAlter TableTable name Modify field Name field type[whether to allow non-empty];--Modify a field type to be attached to a field nameAlter TableTable name change field original Name field new Name field type[whether to allow non-empty]--Delete a fieldAlter TableMyTableDropField name

    • Data manipulation

1. Inserting data

Insert  into Values );

MySQL Basic operation

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.