Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here
Continue with Google
or use

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
Home/ Questions/Q 79933
Next
In Process

Oraask Latest Questions

Question
Chandra
  • 0
  • 0
ChandraExplorer
Asked: July 20, 20222022-07-20T01:07:00+03:00 2022-07-20T01:07:00+03:00In: Oracle SQL

What is the use of ADD, DROP and MODIFY Commands

  • 0
  • 0

What is the use of ADD, DROP and MODIFY Commands?

1
  • 1 1 Answer
  • 110 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Related Questions

    • How to get Column Names from a Table in Oracle
    • What are the different types of case manipulation functions available in Oracle SQL
    • What are the differences between SQL and PL/SQL in Oracle
    • What is the use of LIMIT and OFFSET in SQL
    • How do I get nth sting from comma delimiter string

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Himanshu kumar
      Himanshu kumar Junior TA @GEEKSFORGEEKS | CONTENT CREATOR | FREELANCE CONTENT WRITER |
      2022-07-23T01:22:30+03:00Added an answer on July 23, 2022 at 1:22 am

      ALTER TABLE is used to add, delete/drop or modify columns in the existing table. It is also
      used to add and drop various constraints on the existing table.

      ALTER TABLE – ADD

      ADD is used to add columns into the existing table. Sometimes we may require to add
      additional information, in that case we do not require to create the whole database
      again, ADD comes to our rescue.

      Syntax:

      • ALTER TABLE table_name
        ADD (Columnname_1 datatype,
        Columnname_2 datatype,
        Columnname_n datatype);

      ALTER TABLE – DROP

      DROP COLUMN is used to drop column in a table. Deleting the unwanted columns from
      the table.

      Syntax:

      • ALTER TABLE table_name
        DROP COLUMN column_name;

      ALTER TABLE-MODIFY

      It is used to modify the existing columns in a table. Multiple columns can also be modified
      at once.
      Syntax may vary slightly in different databases. Syntax(Oracle,MySQL,MariaDB):

      • ALTER TABLE table_name
        MODIFY column_name column_type;

       

      Syntax(SQL Server):

      • ALTER TABLE table_name
        ALTER COLUMN column_name column_type;

      Queries
      Sample Table:

      Student

      • ROLL_NONAME
        1 Ram
        2 Abhi
        3 Rahul
        4 Tanu

       

      QUERY:•

      To ADD 2 columns AGE and COURSE to table Student

      • ALTER TABLE Student ADD (AGE number(3),COURSE varchar(40));

       

      OUTPUT:

      • ROLL_NONAMEAGECOURSE
        1 Ram
        2 Abhi
        3 Rahul
        4 Tanu

       

      • MODIFY column COURSE in table Student

       

      • ALTER TABLE Student MODIFY COURSE varchar(20);

       

      After running the above query maximum size of Course Column is reduced to 20
      from 40.

      • DROP column COURSE in table Student.

       

      ALTER TABLE Student DROP COLUMN COURSE;

      • OUTPUT:
        ROLL_NONAMEAGE
        1 Ram
        2 Abhi
        3 Rahul
        4 Tanu
        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    Sidebar

    Adv 250x250

    Explore

    • Categories
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Dev Tools
      • Online Compiler
      • Base64 Converter
      • Oraask XML Formatter
      • Oraask JSON Formatter
    • Wiki
      • SQL Tutorials
      • Java Tutorials
      • Python Tutorials
      • JavaScript Tutorials

    Footer

    Oraask

    About

    Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

    About Us

    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Terms & Conditions

    Follow

    Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

    © 2019 Oraask. All Rights Reserved
    With Love by Oraask.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.