| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Foreign key in Oracle Sql
-CELKO- wrote:
>>>How do I define this table in SQL ? <<
Good try Joe ... but not in Oracle. Not only is it not syntactically correct ... it would not be best practice. Anyone specifying index creation in Oracle, which a primary key will always do if a usable index does not already exist, should be specifying PCTFREE and preferably at 0 so as not to waste space and decrease performance.
SQL*Plus: Release 10.1.0.3.0 - Production on Thu Jan 6 14:23:33 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> CREATE TABLE Rentals
2 (user_id NUMERIC (4) REFERENCES Users(user_id)
3 ON UPDATE CASCADE,
4 tape_id NUMERIC (10) REFERENCES Tapes (tape_id)
5 ON UPDATE CASCADE
6 ON DELETE CASCADE,
7 rental_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
8 PRIMARY KEY (user_id, tape_id, rental_date ));
ON UPDATE CASCADE,
*
ERROR at line 3:
ORA-00905: missing keyword
SQL> In Oracle it is always preferable to create constraints using ALTER TABLE.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond) ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---Received on Thu Jan 06 2005 - 16:25:07 CST
![]() |
![]() |