oracle 數據插入

1、插入完整行

格式:insert into table(

                        xxx_id,

                        xxx_name,

                        ……

                        xxx_address)

                   valus(

                        'xxxxxx',

                        'xxxxxx',

                        ……

                        'xxxxxx');

示例:         

insert into custnew (

                        cust_id,

                        cust_name,

                        cust_address,

                        cust_city,

                        cust_state,

                        cust_zip,

                        cust_country,

                        cust_contact,

                        cust_email)

                   values(

                          '1000000008',

                          'zhang',

                          'shitonglu street',

                          'shijiazhuang', 

                          'sjz',

                          '3333',

                          'china',

                          'sun',

                          '[email protected]');


2、插入檢索出的數據

insert into table1(

                        xxx_id,

                        xxx_name,

                        ……

                        xxx_address

                  select

                        xxx_id,

                        xxx_name,

                        ……

                        xxx_address

                   from table2;

示例:

insert into customers (

                        cust_id,

                        cust_name,

                        cust_address,

                        cust_city,

                        cust_state,

                        cust_zip,

                        cust_country,

                        cust_contact,

                        cust_email)

                  

                 select cust_id,

                        cust_name,

                        cust_address,

                        cust_city,

                        cust_state,

                        cust_zip,

                        cust_country,

                        cust_contact,

                        cust_email

                   from custnew


備註:1、table2檢索出的數據插入到table1,必須先把table2表做填充。

      2、table2的檢索出的值,不能存在table1中,否則提示插入不成功。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章