Alter table 4 Flashcards

1
Q

ADD PRIMARY KEY and REMOVE PRIMARY KEY

A

ALTER TABLE tablename
ADD PRIMARY KEY (id);

ALTER TABLE tablename
DROP PRIMARY KEY;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ADD FOREIGN KEY and REMOVE FOREIGN KEY

A
ALTER TABLE table_name
ADD CONSTRAINT constraint_name
FOREIGN KEY (column_name) REFERENCES table_name(column_name)

ALTER TABLE table_name
DROP FOREIGN KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ADD UNIQUE CONSTRAINT and REMOVE

A

ALTER TABLE table_name
ADD CONSTRAINT constraintname UNIQUE (columnname)

ALTER TABLE tablename
DROP INDEX constraintname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CHANGE COLUMN NAME

A

ALTER TABLE table_name CHANGE oldcolumnname newcolumnname DATA TYPE;
(και αντιστροφα).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CHANGE COLUMN DATA TYPE

A

ALTER TABLE tablename

MODIFY columnname Data Type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly