MySQL Basic data operation

Source: Internet
Author: User

Create data (insert data)
insert into 表名(字段列表) valuse(值列表);insert into exam_student(stu_name,stu_no) values(‘xiaoming‘,‘1205040219‘);

If you need to set values for all the fields when inserting data, you can omit the field list, which is required to match the order of the fields in the table.

insert into exam_student values(‘zhangsan‘,‘3203423‘,100);

Get Data (query data)
select 字段列表 from 表名 查询条件;字段列表可以使用*代替,表示所有的字段。查询条件可以省略,表示所有的记录都获得,相当于where 1;select stu_name,stu_no from exam_student;

alter table exam_student add stu_score int;select * from exam_student;

Conditional lookups:

select * from exam_student where stu_age>50;

Delete Data
delete from 表名 条件;删除需要在逻辑上严格给条件,否则容易造成数据误操作,导致损失。语法上可以没有where。delete from exam_student where stu_age>50;

Modifying Data
update 表名 set 字段=新值,··· 条件;update exam_student set stu_age=88 where stu_age<=50;

MySQL Basic data 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.