当前位置:首页 » 编程语言 » oracle删除sql语句怎么写
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

oracle删除sql语句怎么写

发布时间: 2023-04-08 11:15:24

A. oracle 删除sql语句怎么写

首先你要明确你要删什么东西
如果是删除一个表里面的数据,那你要明确是全表删除还是只删除某一部分数据

表删除语句: delete from 表名where 要删除的条件;
如果是全表删除可以这样写:delete from 表名,或者直接裁剪表 truncate table 表名;

B. oracle数据库删除表中一条数据SQL语句

  1. 保留表,只删除数困稿据:


    truncate table mytable;



    或者:

    delete from mytable where 1 = 1 ;


    commit;

  2. 删除表本身:


    drop table mytable;

C. SQL删除语句怎么写 要多行删除

如果是oracle的话:
比如删除第100条到200之间的记录:
delete from 表名 where rownum > 99 and rownum < 201
sqlserver的话:
delete from 表名 where top > 99 and top< 201

D. 怎么用SQL删除oracle里表的数据

1.保留表,只删除数据:
truncate table mytable;

或者:

delete from mytable where 1 = 1 ;
commit;

2.删除表本身:
drop table mytable;

如果要永久性删除,不准备在恢复:
drop table mytable purge;

不明的可以hi我。

E. 怎么用SQL删除oracle里表的数据

1.保留表,只删除数据:x0dx0atruncate table mytable;x0dx0ax0dx0a或者:x0dx0ax0dx0adelete from mytable where 1 = 1 ;x0dx0acommit;x0dx0ax0dx0a2.删除表本身:x0dx0adrop table mytable;x0dx0ax0dx0a如果要永久性删灶坦除,不准备在恢复:x0dx0adrop table mytable purge;x0dx0ax0dx0a不明隐乎桐的可顷歼以hi我。

F. Oracle语句,如果表XXX存在,删除表XXX,sql语句怎么写

方法一
===================================================
set feedback off
spool c:\del.sql

select 'drop table ' || table_name from all_tables
where table_name like 'XXX';
spool off
@@c:\del.sql
方法二
===================================================
delcare
num number(1);
begin
num:=0;
select count(*) into num from all_tables where table_name like 'XXX';
if num >0 then
exexcute immediate 'drop table XXX';
end if
end ;
/

G. Oracle 查询并删除重复记录的SQL语句,如下内容

1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断

select * from people

where peopleId in (select peopleId from people group by peopleId
having count(peopleId) > 1)

2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有 rowid最小的记录

delete from people

where peopleId in (select peopleId from people group by peopleId
having count(peopleId) > 1)

and rowid not in (select min(rowid) from people group by peopleId having
count(peopleId )>1)

注:rowid为oracle自带不用该.....

3、查找表中多余的重复记录(多个字段)

select * from vitae a

where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by
peopleId,seq having count(*) > 1)

4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录

delete from vitae a

where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by
peopleId,seq having count(*) > 1)

and rowid not in (select min(rowid) from vitae group by peopleId,seq having
count(*)>1)

5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录

select * from vitae a

where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by
peopleId,seq having count(*) > 1)

and rowid not in (select min(rowid) from vitae group by peopleId,seq having
count(*)>1)