insert into 表名(列名列表) values(值列表);
注意:
1)添加一条记录
2) 值列表的顺序和类型及个数 与列名列表对应的
3) 值列表中除了数值类型外,其他类型的值使用单引号引起来。
4) 给可空列赋值为空 4.1)列列表中不写此列 4.2)值写为null
5)给有默认值的列直接使用默认值时 5.1) 列列表中不写此列 5.2) 值写为default
6) 列名列表可以省略,注意值列表的顺序要与定义表时列的顺序一致 (不建议使用)
学生表select * from studentInfo;给学生表中添加一条数据
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(1,'张三','男',21,'32165498747','[email protected]','北京海淀');值与列顺序和类型一致
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values('张三',1,'男',21,'32165498747','[email protected]','北京海淀');--类型不一致错误值的个数与列的个数的一致
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(2,'张帅','女',21,'32165498745','[email protected]');--没有足够的值
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(2,'张帅','男',21,'32165498745','[email protected]','北京海淀','描述'); --值过多给可空列赋值为null地址列为空 (省略此列名)
insert into studentInfo(studentId,stuName,sex,age,phone ,email) values(2,'张帅','男',21,'32165498745','[email protected]');值写为null
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(9,'大山','男',22,null,'[email protected]',null);给有默认值的列使用默认值省略有默认值的列
insert into studentinfo(studentId,stuName,age,phone,address) values(10,'李林',21,'14785236956','北京西城');值中写default
insert into studentInfo(studentid,stuname,sex,age, phone,email,address) values(11,'蔡徐坤',default,20,'45632178954',default,null);省略列名列表
insert into studentinfo values(12,'邓伦',default,22,null,null,default);提交数据
commit;
推荐教程:《Oracle视频教程》
以上就是总结整理Oracle的添加语句(总结分享)的详细内容,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)