Home » SQL & PL/SQL » SQL & PL/SQL » how can i create table
how can i create table [message #196678] Fri, 06 October 2006 08:32 Go to next message
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 Go to previous messageGo to next message
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 #196682 is a reply to message #196681] Fri, 06 October 2006 08:49 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
it means...
both detlorder_no & product_no having primary key..
is this possible weather oracle except this type of table.
Re: how can i create table [message #196683 is a reply to message #196678] Fri, 06 October 2006 08:52 Go to previous messageGo to next message
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 #196687 is a reply to message #196683] Fri, 06 October 2006 09:00 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
thanxx Cthulhu
one more request to u..
can u please write down the create table command of it,
so that it will make me understand.
Re: how can i create table [message #196690 is a reply to message #196678] Fri, 06 October 2006 09:17 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 #196694 is a reply to message #196690] Fri, 06 October 2006 09:33 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
oh my god !!!!
u had dropped all those three table which contains data.
In table product_master i m having product_no as primary key.
In table sales_order i m having order_no as primary key.
why should i dropped that.
i simply want to create table of it.
do i have to dropped all those table .
then sorry dear.i will not creat it
thanx a lot Cthulhu Embarassed
Re: how can i create table [message #196695 is a reply to message #196678] Fri, 06 October 2006 09:35 Go to previous messageGo to next message
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 #196696 is a reply to message #196695] Fri, 06 October 2006 09:42 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
i kn what i m doing also having idea but u fail to satisfy me.
ok no prb i will try myself.
thank u lot Cthulhu u hve spent lot of time with me
Re: how can i create table [message #196718 is a reply to message #196696] Fri, 06 October 2006 14:51 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"u fail to satisfy me" Very Happy

So much effort for nothing; it appears that you would have done better if you watched birds through the window instead of spoon-feeding the OP, Neal Smile

By the way, Ashish, how do you mean "YOU dropped three tables"? Did Neal connect to your database and dropped them, or did you run the script without having even a general idea of what those lines mean?
Re: how can i create table [message #196728 is a reply to message #196718] Fri, 06 October 2006 16:14 Go to previous message
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."
Previous Topic: Dynamic lists with multiple selections possible
Next Topic: how it's working?
Goto Forum:
  


Current Time: Sun Dec 08 06:38:11 CST 2024