• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Oracle中两表之间值互相插入和表自身插入值

mysql 搞代码 4年前 (2022-01-09) 17次浏览 已收录 0个评论

有两张表student和otherStudent,表信息如下 SQLgt; desc studentName Type Nullable Default Comments —- ———

有两张表student和otherStudent,表信息如下

SQL> desc student
Name Type Nullable Default Comments
—- ———— ——– ——- ——–
NUM NUMBER
NAME VARCHAR2(20)
AGE NUMBER Y

SQL> desc otherStudent
Name Type Nullable Default Comments
—- ———— ——– ——- ——–
NUM VARCHAR2(50)
NAME VARCHAR2(50)

现在做以下几个实验

实验一

现在student中有数据,,我想把里面的数据插入otherStudent里面。

insert into otherStudent(num,name) select num,name from student

两表插入的字段类型或长度并补一致仍然可以插入,说明只要被插入的表可以接收,类型不一致或长度不一致不影响。

实验二

othe来@源gao*daima.com搞@代#码网rStudent有了数据了,可以将该表的数据再插入本表

insert into otherStudent select * from otherStudent

实验三

语句insert into otherStudent select * from student。报错“值过多”。

语句insert into student select * from student otherStudent。报错“没有足够的值”。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Oracle中两表之间值互相插入和表自身插入值
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址