SlideShare a Scribd company logo
1 of 2
SQL(Oracle) Queries
DDL (Data definition language)
TABLE
Create table CREATE TABLE<table_name>
(< column_name1> <datatype> [<constraint>],
< column_name2> <datatype> [<constraint>],…);
Show tables list Select * from TAB;
Describe table(table structure) DESCRIBE <table_name>;
Delete/Drop table DROP TABLE <table_name>;
Rename table RENAME <old_table_name>TO <new_table_name>;
Add a column ALTER TABLE <table name>
ADD <new_column_name> <datatype> [<constraint>];
Rename a column ALTER TABLE <table name>
RENAME COLUMN <old_column_name> TO
<new_column_name>;
Delete a column ALTER TABLE <table name>
DROP <column_name>;
Modify datatype or
size
ALTER TABLE <table name>
MODIFY <column_name> <datatype> [<constraint>];
COLUMN
CONSTRAINTS
Constraints Add constraint Drop constraint
Not null ALTER TABLE <table name>
MODIFY <column_name>
CONSTRAINT <constraint_name>NOT NULL;;
ALTER TABLE <table name> MODIFY
<column_name> NULL;
Unique ALTER TABLE <table name>
ADD CONSTRAINT <constraint_name>
UNIQUE (<column_name>);
ALTER TABLE <table name>
DROP CONSTRAINT
<constraint_name>;
Check ALTER TABLE <table name>
ADD CONSTRAINT <constraint_name>
CHECK (<column_name><condition>);
ALTER TABLE <table name>
DROP CONSTRAINT
<constraint_name>;
Primary
key
ALTER TABLE <table name>
ADD CONSTRAINT <constraint_name>
PRIMARY KEY (<column_name>);
ALTER TABLE <table name>
DROP CONSTRAINT
<constraint_name>;
Default ALTER TABLE <table name>
MODIFY <column_name> DEFAULT <value>;
ALTER TABLE <table name>
MODIFY <column_name> DEFAULT
NULL;
Foreign key ALTER TABLE <table name>
ADD CONSTRAINT <constraint_name>
FOREIGN KEY (<column_name> )
REFERENCES <table name1> (<column_name> );
ALTER TABLE <table name>
DROP CONSTRAINT
<constraint_name>;
DML (Data Manipulation language)
INSERT
Insert into all columns INSERT INTO <table_name>
VALUES (<column1_value>,< column2_value>,……);
Insert into specific columns INSERT INTO <table_name> (<column1>, <column2>,…)
VALUES (<column1_value>, <column2_value>,……);
SELECT
Select all data (all rows all columns – full
table)
SELECT *
FROM <table_name>;
Select specific columns SELECT <column1, column2,….>
FROM <table_name>;
Select all data based on condition SELECT *
FROM <table_name> WHERE<condition>;
Select data in ascending/descending
order
SELECT *
FROM <table_name>
ORDER BY <column1><ascending/descending>;
UPDATE
Update values which satisfy condition UPDATE <table_name>
SET <column_name>=<new_value>;
Update all values of a specific column(same
values for a particular column)
UPDATE <table_name>
SET <column_name>=<new_value>
WHERE<condition>;
DELETE
Delete specific rows based on condition DELETE
FROM <table_name>
WHERE<condition>;
Clear all data of a table(delete all rows) DELETE
FROM <table_name>;
Identifiers-
An Identifier is essentially a name of a database_name, table_name, column_name or constraint_name.
Rules-
1. First letter must be alphabet (a-z, A-Z).
2. Second and other letters can be numbers (0-9), alphabet (a-z, A-Z) and _ (underscore).
3. Must not be a keyword.

More Related Content

What's hot

Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteAl-Mamun Sarkar
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL CommandsShrija Madhu
 
SQL Quick Reference Card
SQL Quick Reference CardSQL Quick Reference Card
SQL Quick Reference CardTechcanvass
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHEREI L0V3 CODING DR
 
Avinash database
Avinash databaseAvinash database
Avinash databaseavibmas
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML StatementsA Data Guru
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsAshwin Dinoriya
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in databaseHemant Suthar
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table1keydata
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL Rc Os
 

What's hot (17)

Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
SQL Quick Reference Card
SQL Quick Reference CardSQL Quick Reference Card
SQL Quick Reference Card
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERE
 
Ddl commands
Ddl commandsDdl commands
Ddl commands
 
Avinash database
Avinash databaseAvinash database
Avinash database
 
Sql Tags
Sql TagsSql Tags
Sql Tags
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML Statements
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table
 
Sql cheat-sheet
Sql cheat-sheetSql cheat-sheet
Sql cheat-sheet
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 

Viewers also liked

Abstract classes and Methods in java
Abstract classes and Methods in javaAbstract classes and Methods in java
Abstract classes and Methods in javaHarish Gyanani
 
Sql like operator examples
Sql like operator examplesSql like operator examples
Sql like operator examplesHarish Gyanani
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in javaHarish Gyanani
 
40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanationHarish Gyanani
 
File handling in c language
File handling in c languageFile handling in c language
File handling in c languageHarish Gyanani
 

Viewers also liked (6)

Basic MySQL queries
Basic MySQL queriesBasic MySQL queries
Basic MySQL queries
 
Abstract classes and Methods in java
Abstract classes and Methods in javaAbstract classes and Methods in java
Abstract classes and Methods in java
 
Sql like operator examples
Sql like operator examplesSql like operator examples
Sql like operator examples
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
 
40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation
 
File handling in c language
File handling in c languageFile handling in c language
File handling in c language
 

Similar to Basic sql(oracle) queries

Similar to Basic sql(oracle) queries (20)

Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
 
MY SQL
MY SQLMY SQL
MY SQL
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql reference from w3 schools
Sql reference from w3 schools Sql reference from w3 schools
Sql reference from w3 schools
 
SQL
SQLSQL
SQL
 
Learn plsql
Learn plsqlLearn plsql
Learn plsql
 
dbms.pdf
dbms.pdfdbms.pdf
dbms.pdf
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Sql
SqlSql
Sql
 
SQL Query
SQL QuerySQL Query
SQL Query
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Oracle truncate&amp;alter (1)
Oracle truncate&amp;alter (1)Oracle truncate&amp;alter (1)
Oracle truncate&amp;alter (1)
 
Les02
Les02Les02
Les02
 
Sqlbysandeep
SqlbysandeepSqlbysandeep
Sqlbysandeep
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
Sql presentation 1 by chandan
Sql presentation 1 by chandanSql presentation 1 by chandan
Sql presentation 1 by chandan
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Lecture 3 sql {basics ddl commands}
Lecture 3 sql {basics  ddl commands}Lecture 3 sql {basics  ddl commands}
Lecture 3 sql {basics ddl commands}
 

Recently uploaded

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Basic sql(oracle) queries

  • 1. SQL(Oracle) Queries DDL (Data definition language) TABLE Create table CREATE TABLE<table_name> (< column_name1> <datatype> [<constraint>], < column_name2> <datatype> [<constraint>],…); Show tables list Select * from TAB; Describe table(table structure) DESCRIBE <table_name>; Delete/Drop table DROP TABLE <table_name>; Rename table RENAME <old_table_name>TO <new_table_name>; Add a column ALTER TABLE <table name> ADD <new_column_name> <datatype> [<constraint>]; Rename a column ALTER TABLE <table name> RENAME COLUMN <old_column_name> TO <new_column_name>; Delete a column ALTER TABLE <table name> DROP <column_name>; Modify datatype or size ALTER TABLE <table name> MODIFY <column_name> <datatype> [<constraint>]; COLUMN CONSTRAINTS Constraints Add constraint Drop constraint Not null ALTER TABLE <table name> MODIFY <column_name> CONSTRAINT <constraint_name>NOT NULL;; ALTER TABLE <table name> MODIFY <column_name> NULL; Unique ALTER TABLE <table name> ADD CONSTRAINT <constraint_name> UNIQUE (<column_name>); ALTER TABLE <table name> DROP CONSTRAINT <constraint_name>; Check ALTER TABLE <table name> ADD CONSTRAINT <constraint_name> CHECK (<column_name><condition>); ALTER TABLE <table name> DROP CONSTRAINT <constraint_name>; Primary key ALTER TABLE <table name> ADD CONSTRAINT <constraint_name> PRIMARY KEY (<column_name>); ALTER TABLE <table name> DROP CONSTRAINT <constraint_name>; Default ALTER TABLE <table name> MODIFY <column_name> DEFAULT <value>; ALTER TABLE <table name> MODIFY <column_name> DEFAULT NULL; Foreign key ALTER TABLE <table name> ADD CONSTRAINT <constraint_name> FOREIGN KEY (<column_name> ) REFERENCES <table name1> (<column_name> ); ALTER TABLE <table name> DROP CONSTRAINT <constraint_name>;
  • 2. DML (Data Manipulation language) INSERT Insert into all columns INSERT INTO <table_name> VALUES (<column1_value>,< column2_value>,……); Insert into specific columns INSERT INTO <table_name> (<column1>, <column2>,…) VALUES (<column1_value>, <column2_value>,……); SELECT Select all data (all rows all columns – full table) SELECT * FROM <table_name>; Select specific columns SELECT <column1, column2,….> FROM <table_name>; Select all data based on condition SELECT * FROM <table_name> WHERE<condition>; Select data in ascending/descending order SELECT * FROM <table_name> ORDER BY <column1><ascending/descending>; UPDATE Update values which satisfy condition UPDATE <table_name> SET <column_name>=<new_value>; Update all values of a specific column(same values for a particular column) UPDATE <table_name> SET <column_name>=<new_value> WHERE<condition>; DELETE Delete specific rows based on condition DELETE FROM <table_name> WHERE<condition>; Clear all data of a table(delete all rows) DELETE FROM <table_name>; Identifiers- An Identifier is essentially a name of a database_name, table_name, column_name or constraint_name. Rules- 1. First letter must be alphabet (a-z, A-Z). 2. Second and other letters can be numbers (0-9), alphabet (a-z, A-Z) and _ (underscore). 3. Must not be a keyword.