Skip to main content

Class 2 Statements in Oracle DDL

Statements in Oracle

Statements in Oracle is very much important topic to understand rest other topics better, so there will be lot of important interview questions will be there in this chapter.

This statements in Oracle is also called as Subset of oracle statements.

Before entering in to the statements in oracle, everyone should know the basic understanding about Data types in Oracle with that clear content will be much used to understand this subset concept will be easy to learn.

statements in oracle


Overview of Statements in Oracle

  • At the end of this chapter you will get clear Understanding about the statements of oracle

  • With the help of this statements, you can easily create database objects like Tables

  • Able to create tables, columns, filling the data and merging and other privileges related parts will be seen here.

  • DDL, DML, DCL, TCL are explained very well in this post.

  


POINTS TO REMEMBER:


  1. Always use underscore while naming any table or columns. Example: Instead of using customer name, use customer_name.

  2. Can't be able to change the data type from VARCHAR2 to NUMBER, if data is present inside the column. [In MODIFY command of alter command in DDL ]

  3. Don’t forget to mention the keyword (“Column” for RENAME and DROP alter command)

  4. No need to mention the keyword (“Table” for RENAME command).

  5. Don’t confuse ALTER column level command and DDL table level command.


DATA DEFINE LANGUAGE


  • It is Auto commit Statement, so no need to give commit in this transaction, this commit can be detailed explanation in TCL (Transaction Control Language)
  • This DDL (Data Define Language) is used to give a structure to the particular table and as well as creating a table and doing any changes inside the table.

CREATE

ALTER [Command Level]

RENAME

DROP

TRUNCATE


Shortcut to remember this

data define language shortcut in oracle


CREATE COMMAND


  • It is used to create a table

  • Syntax: CREATE TABLE table_name (Column_name datatype(size))


Example


CREATE TABLE orders (id NUMBER);


Orders -> Table name

Id -> column name

Number -> data type.


CREATE COMMAND in Oracle statements


ALTER COMMAND


  • It is used to create a structure for a table

  • By using this we can do any changes in the columns (Alter command)

  • This alter command is subdivided into 4 categories.

ADD

REMOVE

MODIFY

DROP


NOTE: The above command add, remove, modify and drop can be used only for column level only. If we use without an alter command it will act in the table.



ADD

Used to add a new column in a existing table

Syntax: ALTER TABLE table_name ADD column_name DATATYPE




RENAME

Used to rename a existing column in a table

Syntax: ALTER TABLE table_name RENAME column old_name TO new_name




MODIFY

Used to change the data type of particular column

Syntax: ALTER TABLE table_name MODIFY column_name new DATATYPE




DROP

Used to drop the column in a existing table

Syntax: ALTER TABLE table_name DROP column column_name




RENAME COMMAND


  • It is used to change the name of the table


RENAME COMMAND in sql statements


DROP COMMAND


  • It is used to drop the table, and as well as there won’t be any records

  • After dropping the table, if you try to view the table it will throw an error like table or view does not exist.


TRUNCATE COMMAND


  • It is used to delete the records in the table.

  • Here the structure is not disturbed.

  • The table name, column name and everything will remain the same.



data define language statements in oracle
PRACTICAL SESSION FOR ORACLE STATMENTS 


CREATE TABLE reli (id NUMBER);

Table Created.


ALTER TABLE reli ADD name VARCHAR2(20);


Table altered.


ALTER TABLE reli RENAME COLUMN name TO customer_name;


Table altered.


ALTER TABLE reli MODIFY customer_name VARCHAR2(80);


Table altered.


ALTER TABLE reli DROP COLUMN customer_name;


Table altered.



IMPORTANT INTERVIEW QUESTION

1, What is DDL in oracle Statements ?
2, What are the commands in DDL of oracle statements ?
3, What are the command that are used for column level in oracle statements ?
4, Syntax to remove the records from the table ?
5, Syntax to change the data type of the particular columns
6, Syntax to add new columns to the existing table ?
7, Difference between TRUNCATE and DELETE ?    Most Important

NOTE: Must read the points to remember, which is given beginning of the chapter.

CONCLUSION

I hope now you got some clear understanding about the data define languages, so if you found any error or doubts in the above content means kindly feel free to ask us in the contact form or else through official mail.





Comments

Popular posts from this blog

Oracle SQL Interview Questions Series 1 [Basic]

Oracle SQL Interview Questions Series - 1 Oracle SQL Interview Questions covered in Eduflee, so complete all the series to get placed into the IT company. At present Structured Query Language is very important to enter into the Software company. After completing all the Interview series, you can crack many interviews with 100% assurance from my experience. Basic Questions for SQL interview Schema => User Records => Rows Fields => Columns Result set => Output 1, What are the Schema Objects in Oracle SQL ?     Table, View, Materialized view, Sequence, Synonyms, Index are the schema objects in SQL.     Table => Basic Unit of Storage [Rows and Columns]     View => Logical Representation of subject of records, It does not contains any data. So here data is logical.     Materialized View =>   It contains the data, it is also called as Snapshot. It contains data physically.     Sequence => It is a Numeric Value Generator     Synonyms => used to provide alternate nam

Class 3 Functions in Oracle SQL

Functions in Oracle SQL Functions is one of the important features in Oracle SQL, with the help of this functions we can able to get the result as per our requirement. Functions in Oracle SQL contains Single Row Functions, Multiple Row Functions. Mainly those functions are used to returns value based on the input that which we given. And practicing this functions in oracle SQL, one can able to master in query writing. Functions is used to perform some actions like doing any calculations, grouping the data, conversion in type, date conversion etc. Types of Functions in Oracle SQL Functions in oracle is classified on the basis of the input which we are giving and getting the output, and they are: - Single Row Functions - Multiple Row Functions Single Row Functions in Oracle SQL Single Row Functions works on the single rows which will shows the result for that single rows only. If "n" number of inputs to give "n" number of outputs. From the above figure explains about

Learn SQL From Scratch to Advanced topics

Learn SQL from Scratch to Advanced  Nowadays, many IT company moreover depend on SQL  only. So this is one of the basic query language to start for new developers. So track or to be master in SQL, the below topics should be covered. List of Basic Topics :- 1, Should know what is frontend and backend developer  2, What is DBMS, RDBMS ? 3, What is SQL ? 4, What are the database are there ? Beginner Level SQL topics  This are some beginner level SQL topics, if you are new to SQL this are the topics that should be covered first. 1, Oracle Basics  2, List of Objects in SQL   3 , Clause and its usage   4, Functions  5, Sub Query  6, Joins  7, Decode and Case 8, Constraints 9, Important Data Dictionary Table like user_source, all_source, user_tables etc.., Intermediate Level SQL topics (Creating Objects)  When we are entering into objects this below topics should be covered. In  this topics that we are creating database objects like tables, views, sequences, synonyms etc. 1, Data Definitio