By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

How to assign a primary key

P: 34
this is sonu. i am new to thiss. i have a doubt in creating table. in creating tables we are taking some key words. my doubt is how asighn key words (primary and forign key) to names in a table.
i am creating 3 tables about employee
leave table, leavetype table, manger table
in this 3 tables emp code is primary key
and leave date is forign key

Q: how to create table emp code as primary key and leave date as forighn key.

please help to me
Apr 17 '07 #1
Share this Question
Share on Google+
2 Replies

P: 34
any way thanks to all.
i got the answer from books

for primary key assighn ex:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE Leavetable ( emp_code varchar(25) primary key NOT NULL, fdate date, update date, first_half date, second_half date, no_of_days integer [3] );
for foreighn key asighn ex:
Expand|Select|Wrap|Line Numbers
  1.  CREATE TABLE Leavetype ( emp_code varchar(25) references leavetable(emp_code), date date, type_of_leave varchar, reason char [50] );
thanks again to all
Apr 17 '07 #2

Expert 100+
P: 534
any way thanks to all.
I got the answer from books
... ... ...
You did the right thing - If all fails, read the manual! :)

You may also want to look at the Constraints doc.
Apr 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.