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;
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
3
Q
ADD UNIQUE CONSTRAINT and REMOVE
A
ALTER TABLE table_name
ADD CONSTRAINT constraintname UNIQUE (columnname)
ALTER TABLE tablename
DROP INDEX constraintname
4
Q
CHANGE COLUMN NAME
A
ALTER TABLE table_name CHANGE oldcolumnname
newcolumnname
DATA TYPE;
(και αντιστροφα).
5
Q
CHANGE COLUMN DATA TYPE
A
ALTER TABLE tablename
MODIFY columnname Data Type