How to do modifications to columns in SQL
First let us create Employee table in our database.
Modification to existing column in table:
Adding new column into the table:
Removing the column from a table:
Removing the table from database:
CREATE TABLE [dbo].[Employee]([EmpID] [int] NOT NULL,[FirstName] [nvarchar](250) NOT NULL,[LastName] [nvarchar](250) NULL,[Salary] [money] NULL,[DeptID] [int] NULL)
ALTER TABLE [dbo].[Employee]ALTER COLUMN [DeptID] INT NOT NULL
Adding new column into the table:
ALTER TABLE [dbo].[Employee]ADD Phone INT NULL
Removing the column from a table:
ALTER TABLE [dbo].[Employee]DROP COLUMN Phone
Removing the table from database:
DROP TABLE [dbo].[Employee]
Labels: alter column, alter table, DDL in SQL, DML in SQL, drop, how to alter the column in sql, remove column in sql, SQL Basics, SQL Learning
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home