how can i create table [message #196678] |
Fri, 06 October 2006 08:32 |
ashish_pass1
Messages: 114 Registered: August 2006 Location: delhi
|
Senior Member |
|
|
sir,
i unable to understand the table.
table is like this.
Column Name Data Type Size Attribute
detlorder_no varchar2 6 primary key,foreign key
references of order_no of
sales_order table.
product_no varchar2 6 primary key,foreign key
references product_no of
product_master table.
qty_ordered number 8
qty_disp number 8
product_rate number 8,2 not null
what does this primary key, foreign key represents.
in a table there's only one primary key as we kn
can u make me clear abt this table?
thanks in advance
|
|
|
Re: how can i create table [message #196681 is a reply to message #196678] |
Fri, 06 October 2006 08:42 |
Cthulhu
Messages: 381 Registered: September 2006 Location: UK
|
Senior Member |
|
|
The combination of detlorder_no and product_no is the primary key. Detlorder_no is a foreign key to the sales_order table and product_no is a foreign key to the product_master table. The purpose of the table is to show which products are associated with which orders.
|
|
|
|
Re: how can i create table [message #196683 is a reply to message #196678] |
Fri, 06 October 2006 08:52 |
Cthulhu
Messages: 381 Registered: September 2006 Location: UK
|
Senior Member |
|
|
There are not two primary keys, if that is what you mean. There is one primary key with two columns in it. This is perfectly standard in Oracle.
|
|
|
|
Re: how can i create table [message #196690 is a reply to message #196678] |
Fri, 06 October 2006 09:17 |
Cthulhu
Messages: 381 Registered: September 2006 Location: UK
|
Senior Member |
|
|
If you equip yourself with a copy of TOAD from quest software or any other of the GUI tools on the market, you will be able to get hold of the script very easily.
In the meantime (and I'm only doing this because I'm bored stupid - my "employer" doesn't actually believe in giving me any work to do), I think the script would look like this (I've only put the primary key columns on the sales and product tables):
drop table product_master;
drop table sales_order;
drop table product_order;
CREATE TABLE PRODUCT_MASTER (PRODUCT_NO VARCHAR2(6) PRIMARY KEY);
create table sales_order (order_no varchar2(6) PRIMARY KEY);
create table product_order
(detlorder_no varchar2(6) NOT NULL,
product_no varchar2(6) NOT NULL,
qty_ordered number(8),
qty_disp number(8),
product_rate number(8,2));
alter table product_order add constraint pk_product_order primary key (detlorder_no, product_no);
alter table product_order add constraint fk_so_po foreign key (detlorder_no) references sales_order (order_no);
alter table product_order add constraint fk_pm_po foreign key (product_no) references product_master (product_no);
|
|
|
Re: how can i create table [message #196692 is a reply to message #196690] |
Fri, 06 October 2006 09:22 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
I know how you feel!
I'm stuck here testing release scripts.
You can also use DBMS_METADATA.GET_DDL and DBMS_METADATA.GET_DEPENDENT_DDL to extract the DDL required to create any table (or other object) and all the indexes, triggers, constraints etc that depend on that object.
|
|
|
|
Re: how can i create table [message #196695 is a reply to message #196678] |
Fri, 06 October 2006 09:35 |
Cthulhu
Messages: 381 Registered: September 2006 Location: UK
|
Senior Member |
|
|
I put "drop tables" in order to test the script. This is common practice. It is not my fault that you have absolutely no idea what you are doing.
|
|
|
|
|
Re: how can i create table [message #196728 is a reply to message #196718] |
Fri, 06 October 2006 16:14 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
I agree with Cthulhu and JRowbottom.
Cthulhu provided you with a TESTCASE, not with a script you should run on production AS-IS!
I must admit, my first reaction to your remark 'oh my god !!!!
u had dropped all those three table which contains data.' was a ROFL.
As Cthulhu put it so correctly: " It is not my fault that you have absolutely no idea what you are doing."
|
|
|