The document discusses various ALTER commands in SQL that modify database tables. The ALTER command can be used to add or remove columns from a table, modify an existing column's data type or size, add constraints to columns, and rename tables or columns. Examples of the syntax are provided for each type of ALTER command functionality.
The document discusses various ALTER commands in SQL that modify database tables. The ALTER command can be used to add or remove columns from a table, modify an existing column's data type or size, add constraints to columns, and rename tables or columns. Examples of the syntax are provided for each type of ALTER command functionality.
The document discusses various ALTER commands in SQL that modify database tables. The ALTER command can be used to add or remove columns from a table, modify an existing column's data type or size, add constraints to columns, and rename tables or columns. Examples of the syntax are provided for each type of ALTER command functionality.
SYNTAX:- Alter table TableName add ColumnName datatype(size); Example:- Alter table Demo add dept number(2); -->The Alter command to remove a column from table SYNTAX:- Alter Table TableName drop Column ColumnName; Example:- Alter Table demo drop column dept; -->ALTER command used to modify existing column in table:- SYNTAX:- Alter Table TableName modify ColumnName new datatype(newsize); Example:- Alter Table demo modify dept number(5); -->The Alter command to add conatraint for particular column SYNTAX:- Alter Table TableName add CONSTRAINT constraintname constrainttype(ColumnName); Example:- Alter Table demo add Constraint consprin PrimaryaKey(emp_id); -->Rename command:- SYNTAX:- Alter Table TableName Rename to newTableName; Alter Table TableName Rename column oldColumnName to newTableName; Example:- Alter Table demo Rename to demo_emp; Alter Table demo Rename column dept to dept_no.;