语法与其它的sql数据库教程是一样的如下
DELETE FROM COURSES
WHERE COURSE_DESIGNATER = Java
按条件比较复杂的操作方法
DELETE FROM CLASSCONVENINGS
WHERE CLASSES_NUM_FK >
AND CLASS_CONVENE_DATE = TO_DATE( ::
YYYYMMDD HH:MI:SS)
AND CLASS_LOCATION_FK = SeattleTraining Room
下面来看个详细的实例
SQL> create demo table
SQL> create table Employee(
ID VARCHAR( BYTE) NOT NULL
First_Name VARCHAR( BYTE)
Last_Name VARCHAR( BYTE)
Start_Date DATE
End_Date DATE
Salary Number()
City VARCHAR( BYTE)
Description VARCHAR( BYTE)
)
/
Table created
SQL>
SQL> prepare data
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values (Jason Martin to_date(YYYYMMDD) to_date(YYYYMMDD) Toronto Programmer)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(Alison Mathews to_date(YYYYMMDD) to_date(YYYYMMDD) VancouverTester)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(James Smith to_date(YYYYMMDD) to_date(YYYYMMDD) VancouverTester)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(Celia Rice to_date(YYYYMMDD) to_date(YYYYMMDD) VancouverManager)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(Robert Black to_date(YYYYMMDD) to_date(YYYYMMDD) VancouverTester)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(Linda Green to_date(YYYYMMDD) to_date(YYYYMMDD) New York Tester)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(David Larry to_date(YYYYMMDD) to_date(YYYYMMDD) New York Manager)
/
row created
SQL> insert into Employee(ID First_Name Last_Name Start_Date End_Date Salary City Description)
values(James Cat to_date(YYYYMMDD) to_date(YYYYMMDD) Vancouver Tester)
/
row created
SQL>
SQL>
SQL>
SQL> display data in the table
SQL> select * from Employee
/
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
Jason Martin JUL JUL Toronto Programmer
Alison Mathews MAR FEB Vancouver Tester
James Smith DEC MAR Vancouver Tester
Celia Rice OCT APR Vancouver Manager
Robert Black JAN AUG Vancouver Tester
Linda Green JUL JAN New York Tester
David Larry DEC FEB New York Manager
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
James Cat SEP APR Vancouver Tester
rows selected
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> delete command with conditions
SQL>
SQL> delete from Employee where Salary > ;
rows deleted
SQL>
SQL> select * from Employee;
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
Jason Martin JUL JUL Toronto Programmer Celia Rice OCT APR Vancouver Manager
Robert Black JAN AUG Vancouver Tester
James Cat SEP APR Vancouver Tester
rows selected
删除指定的内容
SQL> CREATE TABLE project (
pro_id NUMBER()
pro_name VARCHAR()
budget NUMBER()
CONSTRAINT project_pk PRIMARY KEY (pro_id)
);
Table created
SQL>
SQL>
SQL> INSERT INTO project(pro_id pro_name budget)VALUES ( A);
row created
SQL> INSERT INTO project(pro_id pro_name budget)VALUES ( ERP);
row created
SQL> INSERT INTO project(pro_id pro_name budget)VALUES ( SQL);
row created
SQL> INSERT INTO project(pro_id pro_name budget)VALUES ( CRM);
row created
SQL> INSERT INTO project(pro_id pro_name budget)VALUES ( VPN);
row created
SQL>
SQL>
SQL> SET ECHO ON
SQL> DELETE
FROM project
WHERE pro_id =