Basic SQL: Alter (Part 7)
Alter statement is used to alter the structure of database objects, and like Create statement, different objects have different syntax. Below are example to alter a table:
- Add column:
alter table [table name]
add [column name] [data type]
Example:
alter table temp
add test varchar(10); - Remove column:
alter table [table name]
drop column [column name]
Example:
alter table temp
drop column test; - Add constraint:
alter table [table name]
add constraint [constraint name] [constraint type] [constraint details]
Example:
alter table temp
add constraint temp_uk unique (name); - Remove constraint:
alter table [table name]
drop constraint [constraint name]
Example:
alter table temp
drop constraint temp_uk;
alter user [user name]
identified by [new password]
Example:
alter user james
identified by new_password;

0 comments:
Post a Comment