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

Create Table Question

P: n/a
How would you setup a sample Create Table statement with having to
specify a constraint name for a Primary Key in the table.

Would it go something like this:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN) Constraint PK_SSN, <------ look here ------
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Thanks in advance

Victor
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Originally posted by Victor M .
How would you setup a sample Create Table statement with having to
specify a constraint name for a Primary Key in the table.

Would it go something like this:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN) Constraint PK_SSN, <------ look here ------
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Thanks in advance

Victor

...
DNO INT,
Constraint PK_SSN Primary Key(SSN) ,
...

(BTW the manuals are helpful for finding out correct syntax!)

--
Posted via http://dbforums.com
Jul 19 '05 #2

P: n/a
Victor M. <eh***@hotmail.com> wrote in message news:<MP************************@nntp.slnt.phub.ne t.cable.rogers.com>...
How would you setup a sample Create Table statement with having to
specify a constraint name for a Primary Key in the table.

Would it go something like this:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN) Constraint PK_SSN, <------ look here ------
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Thanks in advance

Victor


The line with the primary key should read

constraint pk_ssn primary key(ssn)


Michael Tubuo Ngong
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.