學習sql有一段時間了
SQL> desc employee
Name Null? Type
emp_id NUMBER(
emp_name VARCHAR
salary NUMBER(
可以通過下面的語句查詢重復的記錄
SQL> select * from employee;
EMP_ID EMP_NAME SALARY
SQL> select distinct * from employee;
EMP_ID EMP_NAME SALARY
SQL> select * from employee group by emp_id
EMP_ID EMP_NAME SALARY
SQL> select * from employee e
where rowid in (select max(rowid) from employe e
where e
e
EMP_ID EMP_NAME SALARY
(
SQL>create table temp_emp as (select distinct * from employee)
SQL> truncate table employee; (清空employee表的數據)
SQL> insert into employee select * from temp_emp; (再將臨時表裡的內容插回來)
(
SQL>delete from employee e
select max(e
e
SQL>delete from employee e
select max(e
e
e
(
SQL>delete from employee where rowid not in (
select max(t
t
EMP_ID EMP_NAME SALARY
SQL> desc employee
Name Null? Type
emp_id NUMBER(
emp_name VARCHAR
salary NUMBER(
可以通過下面的語句查詢重復的記錄
SQL> select * from employee;
EMP_ID EMP_NAME SALARY
SQL> select distinct * from employee;
EMP_ID EMP_NAME SALARY
SQL> select * from employee group by emp_id
EMP_ID EMP_NAME SALARY
SQL> select * from employee e
where rowid in (select max(rowid) from employe e
where e
e
EMP_ID EMP_NAME SALARY
(
SQL>create table temp_emp as (select distinct * from employee)
SQL> truncate table employee; (清空employee表的數據)
SQL> insert into employee select * from temp_emp; (再將臨時表裡的內容插回來)
(
SQL>delete from employee e
select max(e
e
From:http://tw.wingwit.com/Article/program/Oracle/201311/18369.html