标签:student success Addition result above MySQL modification data name
The source of this article is 白居不易
Before the specific work, we should first establish a database containing the data table “student”.(http://www.cnblogs.com/heyangblog/p/7624591.html)
'Addition':Add data 1)Add data for all data in the table Specify all field names in the Insert statement Example:INSERT INTO student(id,name,grade)VALUES(1,'zhangshan',98) The above result is success The field name is not specified in the Insert statement If no field name is specified, the order of the added values should be exactly the same as that of the fields in the table. Example:INSERT INTO student
VALUES (2,'lisi',62); The above result is success 2)Adds data to the specified field of the table Add data for the specified field, that is, add values to only some fields, while the values of other fields are the default values when the table is defined. Example:INSERT INTO student(id,name)
VALUES(3,'wangwu'); The above result is success It can be seen that the grade field value of the new record is null because it indicates the grade value when adding, and the system will automatically add the default value. 3)Other ways to write Insert statements Example:INSERT INTO student
SET id=4,name='zhaoliu',grade=72; The above result is success
4)Add multiple pieces of data at the same time Example:INSERT INTO student VALUES
(5,‘lilei’,99),
(6,'hanmeimei',87),
(8,'poly',76); The above result is success
‘deletion’:Delete from ‘table name’ ‘where’ conditional expression 1)delete some data command:DELETE FROM student
WHERE id=7; The above result is success 2)delete all data command:DELETE FROM student The above result is success ‘modification’:Update data Before executing the following statements, use the insert statement to insert the following data into the student table:
1)Update some data
command:UPDATE student
SET name=‘caocao’,grade=50
WHERE id=1;
The above result is success
2)Update all data
command:UPDATE student
SET grade=80;
The above result is success
'query':Single table query
Before the following operations, let's create a new data table student2
Then insert the following data into the student2 table:
INSERT INTO student2(name,grade,gender)
VALUES ('songjiang',40,'男'),('wuyong',100,'男'),('qinming',90,'男'),('husanniang',88,'女'),('sunerniang',66,'女'),('wusong',86,'男'),('linchong',92,'男'),('yanqing',90,NULL);
1)Simple query Query all fields command:SELECT id,name,grade ,genderFROM student2; The above result is success Query the specified part of the field command:SELECT name,gender FROM student2; The above result is success The amount of tasks is a little large, unfinished to be continued
标签:student,success,Addition,result,above,MySQL,modification,data,name 来源: https://www.cnblogs.com/lixin666/p/15585071.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。