Oracle 新增資料 insert into整理

來源:互聯網
上載者:User

標籤:sql資料庫   ffffff   span   rand   oracle   select   name   where   插入   

一、普遍的方法:insert into 表名(id,name,age,status,欄位N) values(‘id‘,‘name‘,‘age‘,‘status‘,‘欄位N‘);   --建議用這個

              insert into 表名  values(列值);

   執行個體:insert into user(id,name,age,status,role) values(‘1‘,‘小明‘,23,1,‘群主‘); 

              或insert into user   values(‘1‘,‘小明‘,23,1,‘群主‘);  

二、從表裡查詢便捷方法:insert into 表名(id,name,age,status,欄位N)   select id,name,age,status,欄位N  from 表名  where   id=‘id‘;

          執行個體:  insert into user  (id,name,age,status,role)          select    id,name,age,1,‘群主‘       from location_user    l      where l.type=5;  

        注意事項:查詢資料必須是一條資料

 三、小技巧

  主鍵id唯一性,通常用到的是後台方法(java:UUID uuid = UUID.randomUUID();)插入

  以後可以用sys_guid()來代替

  執行個體: insert into user  (id,name,age,status,role)          select    sys_guid(),name,age,1,‘群主‘       from location_user    l      where l.type=5;  

     或者  insert into user(id,name,age,status,role) values( sys_guid(),‘小明‘,23,1,‘群主‘); 

四、其它資料庫方法類似

  mysql資料庫方法:   insert into user_t values(REPLACE(UUID(),‘-‘,‘‘),‘aa‘,‘aa‘,22);   

    sqlServer資料庫新增資料方法:  insert into user_t values(REPLACE( newId(),‘-‘,‘‘),‘aa‘,‘aa‘,22);    

Oracle 新增資料 insert into整理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.