Uploaded on

SQL commands

SQL commands

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
298
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
24
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SQL Structured Query Language
  • 2. SQL is language use for creating, accessing andmanipulating database systems. SQL statements are usedto retrieve and update data in a database. SQL works withdatabase programs like MS Access, DB2, Informix, MS SQLServer, Oracle, Sybase, etc.Database is collection of data Stored in table format.Each table is identified by a name . Tables contain records(rows) and columns.Below is an example of a table called “employee": Id Name Sal 1 Aditya 25000 2 Vaidehi 17000
  • 3. For Performing Operations on the data stored intables different commands are available in sql.SQL commands are categorized in different groupsDDL : Data Definition LanguageDML: Data Manipulation LanguageTCL : Transaction Control Language
  • 4. DATA DEFINITION LANGUAGE(DDL)DDL include three commands•CREATE - Creates a new database table or object.• ALTER - Alters (changes) a database table or Object We can Add ,Modify and Drop column• DROP - Deletes a database table or Object
  • 5. CreateSyntax:Create table table_name( column1 datatype(size), column2 datatype(size), . . columnn datatype(size));Example:Create table Employee(id number(3), name varchar2(10), salary number(10));
  • 6. EFFECT OF CREATE COMMAND Id Name salary
  • 7. AlterSyntax: Alter table table_name ADD/MODIFY/DROP (column specification);Example Alter table employee Add (Address varchar2(10)); Alter table employee modify(Address varchar2(12)); Alter table employee Drop(Adress );
  • 8. EFFECT OF ALTER COMMAND ID NAME SALARY Alter table employee Add (Address varchar2(10)); ID NAME SALARY ADDRESS Alter table employee Drop(Address ); ID NAME SALARY
  • 9. DropSyntax:Drop table table_name;Example:Drop table employee;
  • 10. DATA MANIPULATION LANGUAGE (DML) Data Manipulation Language (DML) includeselect,update,delete,insert: •SELECT - Use for retrieving data from a database table •UPDATE – Use for updating data in a database table •DELETE – Use for deletes data from a database table •INSERT - Use for inserts new data into a database table
  • 11. SELECT STATMENTSyntaxSelect * or column1,column2..column n from table_name[where condition];ExampleSelect * from employee;Select name from employee;
  • 12. INSERT STATMENTSyntaxINSERT INTO table_name[(column1,column2,…)] VALUES (value1, value2,....) ;Example;Insert into emp(id,name,salary)values(101,’Aditya’,100000); Id Name Sal 1 Aditya 100000 2 Vaidehi 17000
  • 13. UPDATE STATMENTSyntax UPDATE table_name SET column_name = new_value WHERE column_name = some_value;Example: update emp set salary=50000 where id=101; Id Name Sal 101 Aditya 50000 102 Vaidehi 17000
  • 14. DELETE STATMENTSyntax DELETE FROM table_name [WHERE column_name = some_value ]Example: delete from employee where id=101; Id Name Sal 102 Vaidehi 17000
  • 15. Thank you!