当前位置:网站首页>【sql语句基础】——增(insert)
【sql语句基础】——增(insert)
2022-06-10 22:00:00 【InfoQ】
增(insert)
insert使用规范
insert代码样例
-- 创建一张商品表goods(id int,goods_name,varchar(10),price double);
CREATE TABLE `goods`(
id INT,
goods_name VARCHAR(10),
pricre DOUBLE);
-- 修改goods表中pricre为price
ALTER TABLE `goods`
CHANGE `pricre` `price` DOUBLE;
-- 使用desc查看表详情
DESC goods
-- 插入一组元素
INSERT INTO `goods` (id,goods_name,price)
VALUES(10,'huawei',5000);
-- 再插入一组元素
INSERT INTO `goods` (id,goods_name,price)
VALUES(11,'iphone',6000);
-- 查看表内容
SELECT * FROM goods;
-- 添加默认为100
price double not null default 100
insert注意事项
- 插入数据应该与字段类型相同。('30'可以添加在int中),'abc'不可以)
- 数据长度应该在规定范围内。
- values中列出的数据位置必须与被加入的列的排列相对应。
- 字符和日期应该加入在' '中。
- 列可以插入空值,前提该字段允许空,insert into table values'null'。
- insert into table_name(列名...) values (),(),(),形成多条记录。
- 如果给表中的所有字段添加数据,可以不写前面的字段名称。
- 默认值的使用,当不给某个字段值时,如果有默认值就会添加默认值,否则报错。(如果某个列,没有指定not null,添加数据时,没有给定值会默认为空)
边栏推荐
- [content co creation] issue 17: summer is hot and you are so sweet! Participating in the signing of Huawei cloud Xiaobian, there is always a pattern gift bag that moves you!
- smb匿名
- UE4 getting started with bone animation
- Reflow and repaint
- Missing heritability
- 2022 Shanghai safety officer C certificate operation certificate examination question bank simulated examination platform operation
- Opencv_ 100 questions_ Chapter III (11-15)
- CCF CSP 202109-1 array derivation
- Keras deep learning practice (8) -- using data enhancement to improve neural network performance
- [006] initial string
猜你喜欢

Custom view: graphics and image processing (I): using simple pictures

Vulnhub练习 DC-1靶机

Reading notes on the way of Huawei data

数组、List、Set、Map、Properties依赖注入格式

200 c language words, please collect!

vulnhub之DC2

C automatically generates Oracle table creation statement according to excel

Blue Bridge Cup_ Pick substring_ Combinatorial mathematics_ Multiplication principle/ Ruler method

Static routing configuration of serial interface in router experiment (Supplement)

Swin_ Interpretation of transformer source code
随机推荐
Distributed Foundation
kubernetes 二进制安装(v1.20.15)(六)部署WorkNode节点
Display of successful cases of target customer matching data table
Icml2022 | revoir la traduction vocale de bout en bout du texte à partir de zéro
Auto.js pro 开发环境配置
同花顺开户怎么样?开户安全吗?
数学与素质教育
Thread pool: a magic weapon for managing threads
Opencv_100问_第三章 (11-15)
laravel8 实现阿里云文件上传
【GMM+KDE】基于MATLAB的GMM和KDE核估计得目标跟踪仿真
Mmdetection dataloader construction
Kubernetes binary installation (v1.20.15) (VI) deploying worknode nodes
IPO can't cure Weima's complications?
A journey of database full SQL analysis and audit system performance optimization
kubernetes多网卡方案之Multus CNI部署和基本使用
Face recognition software based on deepface model
untiy 重置动画
Sherri Monroe被任命为增材制造商绿色贸易协会的新任执行董事
Html+php+mysql login registration page