Sunday, August 13, 2017

How to add new column to your SQL table after publishing

SQL is a very powerful database management tool giving database administrators a variety of advanced ways to manipulate what happens to their data in the data table. But adding a new column to a SQL table with existing data seems difficult as it simply prone to cause errors. This article is written to address the smooth performance of this task. 
 Adding a new column to an existing SQL database table that contains data is achieved using the SQL query stated below but some things have to be critically analyzed.
ALTER TABLE Your_Table_Name ADD Column_Name Data_Type NOT NULL,

Understanding the SQL query


ALTER TABLE is an SQL keyword telling the SQL database server that there is an authorized attempt to modify the structure of a database table whose name is specified in Your_Table_Name ADD  is another SQL keyword telling the server to add this column, whose name is specified in Column_Name to the columns on the specified Your_Table_Name. The data type properties of the new column are specified in the Data_Type. 
Recall that your table is already having data so it would not be coherent adding a column to the table without either setting it to accept Null value or set a default data to the column. This is achieved by adding  NOT NULL as specified above or add default value as it given below.

ALTER TABLE Your_Table_Name ADD Column_Name Data_Type Default 'Your_Default_Value',
With the above query, you are very thorough to altering your table structure in a SQL database.

Share post with family and friends

Trending now

Part A: WORKING WITH CONTAINERS USER CONTOLS IN ASPX WEB PROJECT

ASPX is blessed with a very large number of user controls that developers can mix to design a user-friendly web application interface...

Follow by Email

Most Read Posts