EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Oracle Tutorial Oracle Column
 

Oracle Column

Priya Pedamkar
Article byPriya Pedamkar

Updated March 3, 2023

Oracle Column

 

 

Introduction to Oracle Column

A column in Oracle can be defined as a set of data values which is only of a particular type and is homogenous containing values which can be integer, character, string, images, BLOB and many more and each value in the column represents one value for each row of the oracle database and a table in the oracle database or any other relational database (where data is stored in tabular form) is formed by the columns and rows.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Examples to Implement Oracle Column

Let us now understand a little better with the help of an example:

Example #1: Add a Column in Oracle

In the first point, we will discuss how to add a column in Oracle. ALTER statement is a DDL statement as we are going to change the structure of the table by adding a column.

Code:

ALTER TABLE customers
ADD frequency NUMBER(3);

Output:

DDL statement

Explanation: In this query frequency column of data type NUMBER is being added to the existing table customers. Let us now execute the query in SQL developer and check the result. As we can see in the screenshot the table customers have been successfully altered.

Example #2: Adding Multiple Columns in a Table

In this case, we are going to add more than one column in a table. For this example, we are going to add two columns to the table customers. Let us look at the query for the same.

Code:

ALTER TABLE customers
ADD (frequency NUMBER(3), DOB date);

Output:

Adding Multiple Columns

Explanation: In the query above we are adding the columns frequency and DOB to table customers. Let us execute the query in SQL developer and check the result. As we can see in the screenshot the two columns have been successfully added.

Example #3: Alter Statement to Add Constraint to a Column

In the previous point, we discussed how to add single or multiple columns in a table. So, just as we can add a new column to an existing table, similarly we can also use ALTER statement to modify an existing column in a table and add a new constraint to that specific column. Since the column is already present. So, we will modify the column and ADD a new constraint to it.

Let us go through an example to understand it better. In this example, we are going to add a constraint UNIQUE to one of the existing columns in the table customers already present in the database. Let us prepare the query for the same.

Code:

ALTER TABLE customers
MODIFY customer_name UNIQUE;

Output:

Alter Statement

Explanation: The column is customer_name and we are adding the NOT NULL constraint which will not allow the column to accept duplicate values. As we can see in the screenshot the table has been successfully altered.

Example #4: Rename a Column

RENAME A COLUMN: Just like we can add a new column or modify an existing column in an Oracle database. We can also RENAME the existing columns. We need to use the ALTER statement in order to achieve that milestone. In this example, we will RENAME an existing column to a different or new name. We will try to change the name of the column ‘PLACE’ present in the table ‘CUSTOMERS’ to a different new name. Let us try to prepare the query for the same.

Code:

ALTER TABLE customers
RENAME COLUMN place TO city;

Output:

Rename a Column

Explanation: In the above query the column ‘place’ is being renamed to ’city’. Let us execute the query in SQL developer and check the result. As we can see in the screenshot the column has been successfully renamed.

Example #5: Drop a Column

Just like we can add, modify, and rename an existing column. We can also DROP an existing column from the database. In this example, we are going to drop the column frequency present in the table customers. Let us prepare the query for the same.

Code:

ALTER TABLE customers
DROP COLUMN frequency;

Output:

Drop a Column

Explanation: In the above screenshot, we can see that the column has been successfully dropped and the table has been altered.

Conclusion

In this article we discussed the definition of the column in a database and then we moved on to the various types of operations we can perform on columns. In order to have a better understanding, we went through the syntaxes and examples for each operation.

Recommended Articles

This is a guide to Oracle Column. Here we discuss an introduction to Oracle Column with respective query examples for better understanding. You can also go through our other related articles to learn more –

  1. Oracle CTE
  2. Oracle REPLACE()
  3. Oracle Temporary Table
  4. Oracle EXTRACT()

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW