MySQL Basic operation

Source: Internet
Author: User

Create a table

CREATE TABLE CeShi1 (Uid varchar (primary) key,pwd varchar (), Name varchar (+), Nation varchar (+), foreign key (Nation) References Nation (Code))

Primary KEY Primary Key
Not NULL non-null
Foreign KEY (Nation) references Nation (Code) foreign key
Auto_increment Self-growth

Note: All symbols must be in the English state
Add a semicolon after each table is created
Do not add a comma after the last column in the table is finished

To delete a table:

drop table Pinpai

Operation of data: CRUD operations

1. Add Data:

INSERT into Brand values (' b001 ', ' BMW 5 '); #第一种方式insert into Brand values (' b002 ') and #第二种方式insert into Pinpai values (' ', ' VW '); #处理自增长列

2. Most simple query

SELECT * FROM Pinpai #查询所有数据select * from Pinpai where Ids = 1; #根据条件查询

3. Modify the data

Update Pinpai Set Name = ' Volkswagen ' where Ids = 4; #修改某一条数据update Car set name= ' Harvard ', Time= ' 2012-3-4 ', price=16,brand= ' b002 ' where code= ' c001 '

4. Delete data

Delete from Brand #删除所有数据delete from Pinpai where Ids = 4; #根据条件删除数据

MySQL Basic operation

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.