Add a column with a default value to a table in Oracle SQL


In some situation, you need to add some Default value to a Column in a Table in SQL. For example, In "Login" table, if there is a "username" column which is used to store the username, but if the username is not yet saved then "username" should have by default value "GUEST". So, Let's see how to do it in Oracle SQL.

CREATE TABLE Login ( ID int NOT NULL, USERNAME varchar(255) DEFAULT 'GUEST', PASSWORD varchar(255), LAST_LOGIN_ON date DEFAULT sysdate );

In the above query, two columns "username" and "LAST_LOGIN_ON" have been given default values "GUEST" and sysdate respectively.


Facing Programming Errors. Get Answer within 48 hours:

Giving is the Master Key to Success, in all applications of human life.


For Sponsored Advertisement OR Freelance Programming Article Submission, Contact us at
Recommended Deals Ends in

Quiz Challenge:
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags