473,395 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create Table Question

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
2 6354

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
Hi all, Quick question, how do you create a table in MS Access from with an asp script? I will be creating the table name from Request.querystring("name"), also needs fields of branchname...
4
by: Thomas Jerkins | last post by:
When I write a create table SQL statement I want to add some information about the column heading of each column. How does the exact syntax for the create table look like (which includes this column...
1
by: Stephane Charette | last post by:
QUICK VERSION: How do I create an index on a field of type "MONEY"? ----------------------------- LONG VERSION: I have a table with a field of type "money". I very often need to access...
4
by: Comcast News | last post by:
I have some DDL from DB2/mainframe and it does not list the default value. Example: create table foo ( col1 char(2) not null with default ); Question: So what value does DB2 default in...
1
by: DB_2 | last post by:
Greetings, I was searching Google for ways to turn off transaction logging for some queries. I came across this old post from Feb 2003: > From: fareeda (fareeda@pspl.co.in) > Subject: Re:...
3
by: arch | last post by:
Is there a function or something I can use to generate an sql script for an object in an sql server. for example, I want to generate the CREATE TABLE AS .... statement for a table. I don't want...
33
by: Stef Mientki | last post by:
hello, I discovered that boolean evaluation in Python is done "fast" (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler...
1
by: vincenthkh | last post by:
Hi all, I'm new in using DB2 and I have question on creating/ altering table. I created a file (DDL) with SQL statements, then the database administrator (my client) to create or alter the...
9
by: DottingTheNet | last post by:
help plz!! when i try to cretae a table in a procedure like create procedure blah is begin create table..... ...... end;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.