MySQL basic operation "MySQL"

Source: Internet
Author: User
Tags create index mysql index mysql view
MySQL basic Operation 1.mysql table copy MySQL table structure replication

CREATE table t2 like T2

Replication of MySQL table data

INSERT INTO T2 select * from t1

Operation of the 2.mysql index

2.1 Increase of the index

ALTER TABLE Tb_name Add index index_name (column name)

ALTER TABLE Tb_name add unique (column name)

ALTER TABLE Tb_name add primary key (column name)

2.2 Increase of the index

Create INDEX index_name on tb_name (column name)

2.3 Deletion of the index

ALTER TABLE Tb_name DROP INDEX Index_name

ALTER TABLE Tb_name DROP INDEX name (unique)

ALTER TABLE tb_name drop PRIMARY key

Operation of the 3.mysql view

The MySQL view is an intermediate table created by the condition, and the data changes with the condition

3.1 Increase in views

Create VIEW view_name as condition (SELECT * from T1 where id>5)

3.2 Deletion of views

Drop View View_name

MySQL basic operation "MySQL"

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.