Heim >Datenbank >MySQL-Tutorial >Oracle数据库删除语句DELETE的一般性用法

Oracle数据库删除语句DELETE的一般性用法

WBOY
WBOYOriginal
2016-06-07 14:55:211857Durchsuche

语法与其它的sql数据库教程是一样的,如下 DELETE FROM COURSES WHERE COURSE_DESIGNATER = 'Java110' 按条件比较复杂的操作方法 DELETE FROM CLASSCONVENINGS WHERE CLASSES_NUM_FK 4 AND CLASS_CONVENE_DATE = TO_DATE('2006-02-15 00:00:00', 'YYYY-MM-

语法与其它的sql数据库教程是一样的,如下
DELETE FROM COURSES
WHERE  COURSE_DESIGNATER = 'Java110'

按条件比较复杂的操作方法

DELETE FROM CLASSCONVENINGS
WHERE      CLASSES_NUM_FK      > 4 
  AND CLASS_CONVENE_DATE = TO_DATE('2006-02-15 00:00:00',
                                   'YYYY-MM-DD HH24:MI:SS')
  AND CLASS_LOCATION_FK   = 'Seattle-Training Room 1'
 

下面来看个详细的实例

SQL> -- create demo table
SQL> create table Employee(
  2    ID                 VARCHAR2(4 BYTE)         NOT NULL,
  3    First_Name         VARCHAR2(10 BYTE),
  4    Last_Name          VARCHAR2(10 BYTE),
  5    Start_Date         DATE,
  6    End_Date           DATE,
  7    Salary             Number(8,2),
  8    City               VARCHAR2(10 BYTE),
  9    Description        VARCHAR2(15 BYTE)
 10  )
 11  /

Table created.

SQL>
SQL> -- prepare data
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2               values ('01','Jason',    'Martin',  to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto',  'Programmer')
  3  /

1 row created.

SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values('02','Alison',   'Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver','Tester')
  3  /

1 row created.

SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values('03','James',    'Smith',   to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver','Tester')
  3  /

1 row created.

SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values('04','Celia',    'Rice',    to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, 'Vancouver','Manager')
  3  /

1 row created.

SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn