閱讀64 返回首頁    go 阿裏雲 go 技術社區[雲棲]


oracle中兩表之間值互相插入和表自身插入值


有兩張表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

兩表插入的字段類型或長度並補一致仍然可以插入,說明隻要被插入的表可以接收,類型不一致或長度不一致不影響。

 


實驗二

otherStudent有了數據了,可以將該表的數據再插入本表

insert into otherStudent select * from otherStudent

 


實驗三

語句insert into otherStudent select * from student。報錯“值過多”。

語句insert into student select * from student otherStudent。報錯“沒有足夠的值”。

 

 

最後更新:2017-04-02 15:28:28

  上一篇:go java中自定義annotation
  下一篇:go 8個Linux命令行性能監測工具