Hi, I'm new to SQL. I need to create a table that has a primary key to be used by a CMP entity bean. I used following to create the table: create table my_table(id not null number, val_1 number, val_2 string) ID is the primary key. Does above SQL statement requires id to be unique? If not, what should I do to modify the SQL statement? What should I do to add a foregin key in above statement? Thanks so much.
Joined: Sep 28, 2002
John, to create a Primary key you can use the ALTER command in your existing table by doing the following: ALTER TABLE my_table ADD CONSTRAINT pk_id PRIMARY KEY (id) If you are going to DROP the TABLE and start again use this: CREATE TABLE my_table ( id NUMBER(10,0) NOT NULL, val_1 NUMBER(4,0) NOT NULL, val_2 VARCHAR(12) NOT NULL,