SQL constraint question - TechRepublic
General discussion
November 8, 2005 at 10:28 AM
bradq

SQL constraint question

by bradq . Updated 20 years, 8 months ago

Hello, does anyone know how to do this? I’m supposed to for an assignment and dont even know how to begin. I was hoping someone might be able to explain it.

Using the following CREATE TABLE statements, add AND EXPLICITLY NAME the listed constraints specified for each table. Use the naming convention TableName_ColumnName_ ConstraintTypeAbbreviation for each constraint name. Constraint abbreviations are:

? PK for Primary Key
? FK for Foreign Key
? NN for Not Null.

To complete the exercise:
? All Primary Key constraints should be defined at the table level.
? All NOT NULL constraints should be defined at the column level.
? All Foreign Key constraints should be defined using the ALERT TABLE statement.

STUDENT table:

Add the following constraints to identified columns in the CREATE TABLE statement or the Student table:

PRIMARY KEY – student_id
NOT NULL – lname, fname, phone

CREATE TABLE student
(
student_id NUMBER(5)
lname VARCHAR2(15)
fname VARCHAR2(15)
street VARCHAR2(20)
city VARCHAR2(20)
state CHAR(2)
zip NUMBER(9)
phone NUMBER(10
);

This discussion is locked

All Comments