SQL MODIFY COLUMNIn this SQL article, we will discuss how to modify the column of the table in Structured Query Language. What is MODIFY COLUMN Statement?In many situations, you may require to modify the existing columns or fields of the existing table. So, SQL provides the MODIFY keyword with ALTER TABLE command to overcome this problem. The MODIFY keyword modifies the size, datatype, and constraints of the existing field of the SQL table. Syntax of MODIFY Column statementThis ALTER syntax allows us to modify the single field of the existing table. If you want to modify more than one new field of the same SQL table in a single statement, then you have to use the following syntax: Example of MODIFY Column statement in SQLIf you want to learn how to modify the column of the table, you have to create a new table. The following statement creates the Teacher_Details table in SQL: The below INSERT queries insert the records of Employees with Grades and Remarks in the Employee_Grade table: The following SELECT statement displays the inserted records of the above Employee_Grade table:
Query 1: The following ALTER query modifies the Grade column of the above table: This query makes the Grade column as 'NOT NULL' in the table. Now, this column will not store NULL value. Query 2: The following ALTER query modifies the New_City column of the above Employee_Grade table: This query changes the size of the new city column of the table. Query 3: The following ALTER query modifies the multiple columns of the above table: This query changes the size of the first name, last name, and the first city of the Employee_grade table. Next TopicMAKE_SET Function in SQL |