Consider the table structure shown Table: members Column Name member id last_nam
ID: 3707762 • Letter: C
Question
Consider the table structure shown Table: members Column Name member id last_name first name address CI state phone annual dues payment_date Data Type NUMBER VARCHAR2(50) No VARCHAR2(50) No VARCHAR2(100) Yes VARCHAR2(30 Yes CHAR(2) CHAR(12) NUMBER(5,2) Yes DATE Nullable Default Data Constraint No PK Yes No 52.5 Yes Table: member_groups Column Name member id group_id Data Type NUMBER NUMBER Nullable Default Data No No Constraint PK,FK PK,FK Table: groups Column Name group_id group name Data Type NUMBER Nullable Default Data Constraint No PK VARCHAR2(30) Yes Write a command to add a constraint to the groups table so that the group name in each record is uniqueExplanation / Answer
What I understand from your question is that you have already made the table, now you want to add constraint to that table. So for that you can use ALTER TABLE command.
To add a primary key in table groups, the command will be :
ALTER TABLE groups ADD CONSTRAINT groupsPrimaryKey PRIMARY KEY(group_id);
You can add the same constraint while creating the table,
CREATE TABLE groups (group_id INTEGER PRIMARY KEY, group_name VARCHAR(30));
Hope this helps you. Please reach out if you need any more help.