当前位置:Gxlcms > 数据库问题 > Oracle数据库开发SQL基础之操作表中数据

Oracle数据库开发SQL基础之操作表中数据

时间:2021-07-01 10:21:17 帮助过:7人阅读

       INSERT语句 INSERT INTO table_name(字段的名字,字段的名字)VALUES(VALUE1,VALUE2)

       1.向表中所有字段添加值

          INSERT INTO userinfo

          VALUES (1,‘xxx‘,‘123‘,‘xxx@123.com‘,sysdate)

      2.向表中制定的字段添加值

         INSERT INTO userinfo(id,username,userpwd)

         VALUES(2,‘yyy‘,‘123‘)

         create table userinfo1

         (id number(6,0),

         regdate date default sysdate

         )

         insert into userinfo1(id)

         values(1)

二、复制表数据

      1.创建表时全部复制

      CREATE TABLE userinfo_new

      as

      select*from userinfo

      2.创建表时选择复制

      CREATE TABLE userinfo_new1

      as

      select id,username from userinfo

      3.再添加时全部复制

      INSERT INTO userinfo_new

      select*from userinfo

      4.选择复制

      INSERT INTO userinfo_new(id,username)

      select id,username from userinfo

 三、修改数据

      1.无条件更新

      UPDATE userinfo

      SET userpwd=‘111‘

      UPDATE userinfo

      SET userpwd=‘1‘ ,email=‘1@126.com‘

      2.有条件更新

      UPDATE userinfo

      set userpwd=‘123‘

      where username=‘xxx‘

      3.无条件删除

      create table testd1

      as

      select*from userinfo

      DELETE FROM testd1

      4.有条件删除

      delete from userinfo

      where username=‘yyy‘

Oracle数据库开发SQL基础之操作表中数据

标签:span   .com   ora   复制   com   基础   rom   username   delete   

人气教程排行