Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
15 views
SQL Notes ?
Uploaded by
l1s22bssy0063
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SQL Notes ? For Later
Download
Save
Save SQL Notes ? For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
15 views
SQL Notes ?
Uploaded by
l1s22bssy0063
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SQL Notes ? For Later
Carousel Previous
Carousel Next
Save
Save SQL Notes ? For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
SQL COMMANDS » What is SQL? + Structured Query Language and it helps to make practice on SQL commands which provides immediate results, + SOL is Structured Query Language, which és a. computer language for storing, manipulating and reltieving data stored in relational database, + SQL is the standard language for Relation Database System, + All eclationat database management systems like MySQL, MS Access, and Oracle, Sybase, Informis, ane! SQL Server use SQL as standard database Inngwage, > Why SQL? + Allows users to create and drop databases and tables, * Allows users to describe the data, * Allows users to define the data in database and manipulate that data. + Allows users to access data in relational database management systems * Allows embedding within other languages using SQL modules, libraries & pre-compilers. O Allows users to set permissions on tables, procedures, and views > SQL Arehitecture: + When you are executing an SQL command for any RDBMS, the system os the best way to carry out your request and SQL engine figures ow how to imerpret the task: + There dre various components included in the process, + ‘These components are: © Query Dispatcher o Optimization Engines o Classic Query Engine o SQL Query Engine, ete, + Classic query engine handles all mon-SQL queries but SQL quoty eigine won't handle logical files, + Simple diagram showing SQL Architecture: > SOL Commands: The standard SQL commands to intersect with relational databases are CREATE, SELECT, INSERT, UPDATE, DEI 'E and DROP. + ‘These commands ean be classified into groups based on their nature: > DDL - Data Definition Language: + DDL defines the conceptual schema providing a link between the Tegicdl aind the pligsieal structure of the database. + ‘The functions of the Data Definition Language (DDL) are:1, DDL defines the physical charactes fields length, fields logical name and also specify relationship among those records. 2, DDL describes the schema and subschsma, 3. DDL indicate the keys of records. 4, DDL provides data security measures, 5, DDL provides for the logical and physical dala independence, Few of the basie commands for DDL tics of each record, filed in the record, field's data type, Command Description CREATE. | Creates new table, a view ofa table, or other object in database ALTER | Modifies on existing database object, such as u table, DROP | Deletes am entire table, a view ofa table or other object in the database. > DML - Data Manipulation Language: modification, replacement, retrieval, sorting aud display of data or records, DML facilitates use of relationship between the records, DML. provides for independence of programming languages by supporting several high-level programming languages like COBOL, PL/I and C++ Few of the basic commands for DML are: ‘Command Deseription SELECT | Reirieves certain records from one ar more tables INSERT | Creates a record UPDATE | Modifies records DELETE | Deletes records > DCL - Data Control Language: > TCL — Transaction Control Language These SQL commands are used for provid ‘The different DCL commands are: security to database objects. ‘Command Deseription| GRANT | Gives a privilege to user REVOKE | Takes back pri "ges granted from user It includes commands to control the transactions in a database system, The commonly used commands ave: ML provides the data manipulation wechaiques like selection, insertion, deletion, updation,Command Description COMMIT | Make all the changes made by the statements issued permanent, ROLLBACK | Undoes ail changes since the begi asave point. ing of transaction or since| ¥ Data Types in SQL: “The following are the most common data types of SQL: DATA TYPE DESCRIPTION ‘A variable-length column, Allowed values are zero, 1 | NUMBI positive and negative numbers 2 | CHAR A variable length field up to 255 char ter in length 3. | VARCHAR/VARCHAR2 | A variable length field up to 2000 character in length ‘A fixed length field, The time is stored as a part of the #: AVENE date. The defaul form is DD/MON/YY 5 | LONG A vasiable length filed up to 2 GB in length pia 'A waviable Teng led wsed Tor binary data wp to 2000 in length = A variable lengih fled used Tor binary dats wp to 20B 3: PERE in fength 1, NUMBER: © Used to store a numeri value in a field column, # tmay be decimal, integer or real value. * General syntax: NUMBER(n, €) Where m specifies the number of digi decimal point Example: marks NUMBER(3), average NUMBER, 3) ind d specifies the number of digi (o right of the 2, CHAR: © Used to store charaeter type dat © General syntax: CHAR(size) o Where size represents the maximum (255 Characters) number of charaeters in a column. © Example: name CHAR(IS) in a column, 3. VARCHAR/VARCHAR2: © Itis used to store variable length alphanumeric data. © General syntax: VARCHAR(size) / VARCHAR2%size)© Whete size represents the maximum (2000 Characters) number of characters ina coluntn, + Example: address VARCHAR2(50) 4. DATE: ® Itis used to store date in columns, + SQL supports the various date formats other than the standard D-MON-YY.. + Example: dob DATE 5. TIME: It is used to store time in columns. SQL supports the various time formats other than the standard hh-mmess Every DATE and TIME can be added, subtracted or compared as it can be done with other data types. 6 LONG: | Itis used to store variable length strings of up to 2GB size. 2. Example: description LONG = Structure of SQL command: Any SQL command is a combination of keywords, identifiers and clauses. Every SQL command begins with a keyword (CREATE, CT, DE meaning to the language. and so on) which as SELECT, FROM and WHERE are keywords, + The clauses are “FROM student” and "WHERE RegNo=109", + Here SELECT and FROM are manclatory, but WHERE is optional. + Name, Student, Rego, are identifier that refers t6 objects in the database, + Nameand RegNo are column names, while Student isa table name, ‘The equal sign is an operator and 109 is a numeric constant. >» What is an Operator in SQL? + Anoperator is a reserved word or a character used primarily in an SQL statement’s WHERE clause to perform operation(s}, such as comparisons and arithmetic operations. © Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. o Arithmetic operators (+, =, *, / %) © Comparison operators (>,<, >=, 15, 15) ‘+ Logical operators (AND, OR, NOT, IN, BETWEEN, EXISTS, ALL, ANY, LIKE, UNIQUE)> SQL Logical Operator Here is a list of all the logical operators available in SQL. ‘Operator Deseripti ALL | The ALL operator is used to compare a value to all values in another value set ‘AND | The AND operator allows the existence of multiple conditions in an SQL statement WHERE clause. NY | The ANY operaior is used to compare a value to any applicable value in the list according to the condition, BETWEEN | The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value. EXISTS | The EXISTS operator is used to search for the presence of a row ina specified table that meets certain criteria, N The IN operator iS used 10 compare a value to & list of Tieral values that have been specified, LIKE | The LIKE operator fs used to comparea value to similar values using wildcard operators. NOT _| The NOT operator reverses the meaning of the logical operator with which it i used. By: NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is a negate operator. OR | The OR operator is used to combine multiple conditions in an SQL statemen’s WHERE clause. ISNULL | The NULL operator is used to compare a value with a NULL value. UNIQUE | The UNIQUE operator searchcs every row of a specificd table for uniqueness (no duplicates). > Implementation of SQL Commands ¥ CREATE TABLE + The SQL CREATE TABLE statement is used to ereate a new table, + Creating a basic table involves naming the table and defining it type. + Syntax: Basic syntax of CREATE TABLE statement is as follows: calumns and each column's data CREATE TABLE Table_name ( column! datatype, column? datatype, coluran3 datatype, columnN datatype, PRIMARY KEY( one or more columns ) ):+ Here CREATE TABLE js the keyword followed by the Table_name, followed by an open parenthesis, followed by the column names and data types for that column, and followed by a closed parenthesis, + For each column, a name and a data type must be specified and the column name must be a unique within the table definition. Column definitions are separated by commas (,) Upperease and lowercase letters makes no difference in column names. + Each table must have at least one column, o SQL commands should end icolan (). Example: Create a table “STUDENT” that contains five columns: RegNo, Name, Combination, DOB and Fees, CREATE TABLE STUDENT c RegNo NUMBER (6), Name VARCHAR2 (15), Combination CHAR (4), DOB DATE, Fees NUMBER (9, 2), PRIMARY KEY ( RegNo ) y * Itereates an empty STUDENT table which looks like this RegNo | Name | Combination | DOB | F ip Viewing the table information; ‘o The DESCRIBE or DESC command displays name of the columns, their data type and size along with the constraints, QL? DESCRIBE STUDENT; Nane Null? Type REGHO NOT MULL NUMBER (6) MANE UARCHARZ( 15) COMBINATION CHARGA) 08 DATE FEES NUMBER (442) v ALTER Statement: * The table can be modified or changed by using the ALTER command. + Syntax: Basic syntax of ALTER TABLE statement is as follows: 1, ALTER TABLE Table_name ADD (column_pamel DaType, Clournn_name? DataType...): 2. ALTER TABLE Table_aame MODIFY (column_namel DataType, Cloumn_name2 Data'Type....); 3. ALTER TABLE Table_name DROP (columa_namel DataType. Cloumn_name2 DataType...);+ Example: [SQL> RCRER TaOLE STWOCHT ABO. CRowress VaRCNAR? CaO)): tapte attered. [sQU> mLFER TaMRE STUDENT MmDETY (Hodress UaREHARE (49025 Tapte antered [S0Ly @LTER TABLE STUDENT ORD cADORESS); Tate aaterea. + Using the ALTER TABLE command the following tasks cannot be performed ° ° ° © Changing a table name, Changing the column name. Decreasing the size of a column if table data exists. Changing 8 column's data type. ~ DROP TABLE: + The SQL DROP TABLE statement is used to remove a table definition and all data, indexes, triggers, constraints, sind permission specifications for that table, O Syntax: Basic syntax of - DRO! E> DROP TADLE STUDENT; able dro ¥ INSERT: + The SQL INSERT INTO Statement is used to add new rows of data to a table in the database, + Syntax: ‘There are two basic syntaxes of INSERT INTO statement as follows: + Here, columnl, column?,...calumnN are the names of the columns in the table into which you want to insert data, You may not need to specify the column{s) name in the SQL query if you are adding values for all the columns of the table. But make sure the order of the values is in the same order as the columns in the table, METHOD 1: The SQL INSERT INTO syntax would be as follows: _ Example; Following statements would create sis records in STUDENT ablyor Ranesit GHG o7-quc-99 —sNo0o 402 OHH ‘POHE 45-SEP-99 4403 GANESH AN HANES 4N05. SURESH ai0 anon 4 SHREYA 412 rous selected. ¥ UPDATE: SQL provides the ability to change data through UPDATE command. ‘The UPDATE command used to modify or update an already existing now or sows ofa table, The basic syntax of UPDATE command is given below.¥ DELETE command: + In SOL, an already existing row or rows are removed from tables through the use of DELETE command. * ‘The basie syntax of DELETE command is given below. Example: ¥ SELECT: * SQL SELECT statement is used to fetch the data from a database table which returns data in the form of result table. These result tables are called result-sets. Syntax: The basic syntax of SELECT statement is as follows: SELECT column! column2, columaN | Compulsory FROM Table_name; Part [WHERE condition) Optional [GROUPBY columnelist] Part [HAVING condition(s)] [ORDER BY column-name(s)|; + Here, column1, column3...are the fields of'a table whose values you want to fetch. If you want to fetch all the fields available in the field, then you can use the following syntax: Example: Considers UDENT table Saeies, the following records: o7-nuc-99. kor JOH 15-SEP-99 ‘haa GaNe’sH 19-n00-9 ‘tho MAHESH MO SURESH 4440 ARUN sant SHREYA rows celected. + Following is an example, which would fetch REGNO, NAME and COMBINATION ficlds of the customers available in STUDENT table:Ly SELEET AEGHO, WANE, COWOIMATION FRON STUDENT; ECHO HANE cove. wot RAMESH Powe Powe POM Pee Powe Pee ceon rous selected. ¥ DISTINCT: ‘The SQL DISTINCT keyword is used in conjunction with SELECT statement to eliminate all the duplicate records and fetehing only unique records, ‘There may be. situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only unique records instead of fetching duplicate records, ‘Syntax: The basic syntax of DISTINCT keyword to-eliminate duplicate records is as follows: DISTINCT keyword with the above SELECT query and see the result: This would produce the following result where we do not have any duplicate entry:
You might also like
SQL Tutorial PDF
PDF
No ratings yet
SQL Tutorial PDF
26 pages
SQL Commands
PDF
No ratings yet
SQL Commands
21 pages
Chapter 14 SQL Commands
PDF
No ratings yet
Chapter 14 SQL Commands
25 pages
Data 2
PDF
No ratings yet
Data 2
23 pages
SQL Datatype Is Used To Define The Values That A Column Can Contain. Every Column Is Required To Have A Name and Data Type in The Database Table
PDF
No ratings yet
SQL Datatype Is Used To Define The Values That A Column Can Contain. Every Column Is Required To Have A Name and Data Type in The Database Table
19 pages
chapter-14-sql-commands
PDF
No ratings yet
chapter-14-sql-commands
23 pages
DBMS Unit 3
PDF
No ratings yet
DBMS Unit 3
106 pages
Rdbms File Dabba
PDF
No ratings yet
Rdbms File Dabba
45 pages
SQL Lab Assign
PDF
No ratings yet
SQL Lab Assign
22 pages
DBMS Refresher
PDF
No ratings yet
DBMS Refresher
65 pages
It-222 Reviewer Chap 1 To 4
PDF
No ratings yet
It-222 Reviewer Chap 1 To 4
20 pages
SQL Commands
PDF
No ratings yet
SQL Commands
75 pages
Kamal Rdbms
PDF
No ratings yet
Kamal Rdbms
46 pages
Rdbms File
PDF
No ratings yet
Rdbms File
46 pages
sqlppt
PDF
No ratings yet
sqlppt
67 pages
SQL Commands
PDF
No ratings yet
SQL Commands
58 pages
1 - SQL_DE_Feb25
PDF
No ratings yet
1 - SQL_DE_Feb25
79 pages
Unit 4 SQL
PDF
No ratings yet
Unit 4 SQL
45 pages
SQL Full Notes Reachus
PDF
No ratings yet
SQL Full Notes Reachus
59 pages
CH 14 SQL
PDF
No ratings yet
CH 14 SQL
10 pages
SQL Part
PDF
No ratings yet
SQL Part
60 pages
Structured Query Language
PDF
No ratings yet
Structured Query Language
21 pages
Module 4
PDF
No ratings yet
Module 4
130 pages
SQL Notes
PDF
No ratings yet
SQL Notes
40 pages
SQL Notes by Dhananjay(1)
PDF
No ratings yet
SQL Notes by Dhananjay(1)
32 pages
Xii SQL Full Notes
PDF
No ratings yet
Xii SQL Full Notes
30 pages
Chapter 7
PDF
No ratings yet
Chapter 7
54 pages
Unit 2
PDF
No ratings yet
Unit 2
34 pages
SQL UNIT IV
PDF
No ratings yet
SQL UNIT IV
32 pages
SQL Syntax, Data Types, SQL Operators, Literals, Types of SQL Commands, SQL Keywords, Wildcard Characters Lab 1
PDF
No ratings yet
SQL Syntax, Data Types, SQL Operators, Literals, Types of SQL Commands, SQL Keywords, Wildcard Characters Lab 1
8 pages
Unit - Iv RDBMS Notes
PDF
No ratings yet
Unit - Iv RDBMS Notes
22 pages
What Is SQL?
PDF
No ratings yet
What Is SQL?
37 pages
Unit 3
PDF
No ratings yet
Unit 3
27 pages
SQL
PDF
No ratings yet
SQL
64 pages
CS8481 DBMS RECORD FINAL Modfied
PDF
No ratings yet
CS8481 DBMS RECORD FINAL Modfied
123 pages
Question 1 2
PDF
100% (1)
Question 1 2
38 pages
DBMS_bcom_unit-4
PDF
No ratings yet
DBMS_bcom_unit-4
21 pages
Chapter 9
PDF
No ratings yet
Chapter 9
76 pages
test 3 reading
PDF
No ratings yet
test 3 reading
13 pages
SQL Notes by Apna College
PDF
No ratings yet
SQL Notes by Apna College
29 pages
ISM-AYUSH BANSAL Practical file-BBA 212
PDF
No ratings yet
ISM-AYUSH BANSAL Practical file-BBA 212
20 pages
SQL Commands
PDF
No ratings yet
SQL Commands
62 pages
Structured Query Language (SQL)
PDF
No ratings yet
Structured Query Language (SQL)
29 pages
SQL Notes.pdf1
PDF
No ratings yet
SQL Notes.pdf1
31 pages
(Unit 3) Introduction To SQL: SQL (Structured Query Language)
PDF
No ratings yet
(Unit 3) Introduction To SQL: SQL (Structured Query Language)
30 pages
Unit-3 DBMS Notes
PDF
No ratings yet
Unit-3 DBMS Notes
77 pages
Question 1: Introduction To SQL. Explain What Are Different Types of Data Types in SQL
PDF
No ratings yet
Question 1: Introduction To SQL. Explain What Are Different Types of Data Types in SQL
39 pages
DBMS (Unit2)
PDF
No ratings yet
DBMS (Unit2)
14 pages
Introduction To SQL
PDF
No ratings yet
Introduction To SQL
84 pages
Relational Model-Merged-Pages-1-163,166-211,214-250,253-289,292-343,346-393,396-438
PDF
100% (1)
Relational Model-Merged-Pages-1-163,166-211,214-250,253-289,292-343,346-393,396-438
426 pages
SQL Basics
PDF
No ratings yet
SQL Basics
58 pages
DBMS-LAB-02
PDF
No ratings yet
DBMS-LAB-02
10 pages
SQL Notes by Apna College
PDF
No ratings yet
SQL Notes by Apna College
29 pages
Unit-4_Introduction to Structured Query Language
PDF
No ratings yet
Unit-4_Introduction to Structured Query Language
96 pages
SQL YouTube Course Notes The iScale
PDF
No ratings yet
SQL YouTube Course Notes The iScale
105 pages
SQL Course Step by Step ?
PDF
No ratings yet
SQL Course Step by Step ?
100 pages
Database 3,4
PDF
No ratings yet
Database 3,4
24 pages
SQL Grouping Records, Joins in SQL
PDF
No ratings yet
SQL Grouping Records, Joins in SQL
42 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
SQL Tutorial PDF
PDF
SQL Tutorial PDF
SQL Commands
PDF
SQL Commands
Chapter 14 SQL Commands
PDF
Chapter 14 SQL Commands
Data 2
PDF
Data 2
SQL Datatype Is Used To Define The Values That A Column Can Contain. Every Column Is Required To Have A Name and Data Type in The Database Table
PDF
SQL Datatype Is Used To Define The Values That A Column Can Contain. Every Column Is Required To Have A Name and Data Type in The Database Table
chapter-14-sql-commands
PDF
chapter-14-sql-commands
DBMS Unit 3
PDF
DBMS Unit 3
Rdbms File Dabba
PDF
Rdbms File Dabba
SQL Lab Assign
PDF
SQL Lab Assign
DBMS Refresher
PDF
DBMS Refresher
It-222 Reviewer Chap 1 To 4
PDF
It-222 Reviewer Chap 1 To 4
SQL Commands
PDF
SQL Commands
Kamal Rdbms
PDF
Kamal Rdbms
Rdbms File
PDF
Rdbms File
sqlppt
PDF
sqlppt
SQL Commands
PDF
SQL Commands
1 - SQL_DE_Feb25
PDF
1 - SQL_DE_Feb25
Unit 4 SQL
PDF
Unit 4 SQL
SQL Full Notes Reachus
PDF
SQL Full Notes Reachus
CH 14 SQL
PDF
CH 14 SQL
SQL Part
PDF
SQL Part
Structured Query Language
PDF
Structured Query Language
Module 4
PDF
Module 4
SQL Notes
PDF
SQL Notes
SQL Notes by Dhananjay(1)
PDF
SQL Notes by Dhananjay(1)
Xii SQL Full Notes
PDF
Xii SQL Full Notes
Chapter 7
PDF
Chapter 7
Unit 2
PDF
Unit 2
SQL UNIT IV
PDF
SQL UNIT IV
SQL Syntax, Data Types, SQL Operators, Literals, Types of SQL Commands, SQL Keywords, Wildcard Characters Lab 1
PDF
SQL Syntax, Data Types, SQL Operators, Literals, Types of SQL Commands, SQL Keywords, Wildcard Characters Lab 1
Unit - Iv RDBMS Notes
PDF
Unit - Iv RDBMS Notes
What Is SQL?
PDF
What Is SQL?
Unit 3
PDF
Unit 3
SQL
PDF
SQL
CS8481 DBMS RECORD FINAL Modfied
PDF
CS8481 DBMS RECORD FINAL Modfied
Question 1 2
PDF
Question 1 2
DBMS_bcom_unit-4
PDF
DBMS_bcom_unit-4
Chapter 9
PDF
Chapter 9
test 3 reading
PDF
test 3 reading
SQL Notes by Apna College
PDF
SQL Notes by Apna College
ISM-AYUSH BANSAL Practical file-BBA 212
PDF
ISM-AYUSH BANSAL Practical file-BBA 212
SQL Commands
PDF
SQL Commands
Structured Query Language (SQL)
PDF
Structured Query Language (SQL)
SQL Notes.pdf1
PDF
SQL Notes.pdf1
(Unit 3) Introduction To SQL: SQL (Structured Query Language)
PDF
(Unit 3) Introduction To SQL: SQL (Structured Query Language)
Unit-3 DBMS Notes
PDF
Unit-3 DBMS Notes
Question 1: Introduction To SQL. Explain What Are Different Types of Data Types in SQL
PDF
Question 1: Introduction To SQL. Explain What Are Different Types of Data Types in SQL
DBMS (Unit2)
PDF
DBMS (Unit2)
Introduction To SQL
PDF
Introduction To SQL
Relational Model-Merged-Pages-1-163,166-211,214-250,253-289,292-343,346-393,396-438
PDF
Relational Model-Merged-Pages-1-163,166-211,214-250,253-289,292-343,346-393,396-438
SQL Basics
PDF
SQL Basics
DBMS-LAB-02
PDF
DBMS-LAB-02
SQL Notes by Apna College
PDF
SQL Notes by Apna College
Unit-4_Introduction to Structured Query Language
PDF
Unit-4_Introduction to Structured Query Language
SQL YouTube Course Notes The iScale
PDF
SQL YouTube Course Notes The iScale
SQL Course Step by Step ?
PDF
SQL Course Step by Step ?
Database 3,4
PDF
Database 3,4
SQL Grouping Records, Joins in SQL
PDF
SQL Grouping Records, Joins in SQL