SQL INSERT INTO 语句
INSERT INTO 语句用于向表中插入新记录。
SQL INSERT INTO 语法
INSERT INTO 语句可以有两种编写形式。
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
第一种形式无需指定要插入数据的列名,只需提供被插入的值即可:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
INSERT INTO table_name VALUES (value1,value2,value3,...);
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
第二种形式需要指定列名及被插入的值:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...);
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
插入新的行
"Persons" 表:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
LastName | FirstName | Address | City |
Carter | Thomas | Changan Street | Beijing |
SQL 语句:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
结果:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
LastName | FirstName | Address | City |
Carter | Thomas | Changan Street | Beijing |
Gates | Bill | Xuanwumen 10 | Beijing |
在指定的列中插入数据
"Persons" 表:
文章源自小柒网-https://www.yangxingzhen.cn/7120.html
LastName | FirstName | Address | City |
Carter | Thomas | Changan Street | Beijing |
Gates | Bill | Xuanwumen 10 | Beijing |
SQL 语句:
INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
结果:
LastName | FirstName | Address | City |
Carter | Thomas | Changan Street | Beijing |
Gates | Bill | Xuanwumen 10 | Beijing |
Wilson | Champs-Elysees |
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
![weinxin](https://www.yangxingzhen.com/images/weixin.jpg)
![weinxin](https://www.yangxingzhen.com/images/weixingongzhonghao.png)
评论