0% found this document useful (0 votes)
6 views35 pages

Unit 2

The document provides an overview of Structured Query Language (SQL), including its history, sublanguages, and data types used in Oracle. It explains the features of SQL and SQL*PLUS, along with various data types such as CHAR, VARCHAR, DATE, NUMBER, LONG, and RAW. Additionally, it emphasizes the importance of choosing appropriate data types for database performance.

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views35 pages

Unit 2

The document provides an overview of Structured Query Language (SQL), including its history, sublanguages, and data types used in Oracle. It explains the features of SQL and SQL*PLUS, along with various data types such as CHAR, VARCHAR, DATE, NUMBER, LONG, and RAW. Additionally, it emphasizes the importance of choosing appropriate data types for database performance.

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Structured Query Language (SQL):-

1
2.1 Structured Query Language (SQL):-

• Overview of SQL,
• Data Types in Oracle,
• Sublanguages of SQL-
– Data Definition Language (create, alter, truncate, drop),
– Data Manipulation Language (insert, select, update, delete),
• Sorting of data,
• Aggregate functions,
• Grouping data from tables (Group by and having clause), and
• SET operators in oracle (Union, Intersect, Minus),
• Oracle transactions.

2
3
Introduction to Oracle
• Way back in June 1970, Dr E. F. Codd published a paper entitled A
Relational Model of Data for Large Shared Data Bank.

• This relational model, sponsored by IBM, then came to be accepted


as the definitive model for RDBMS.

• The language developed by IBM to manipulate data stored within


Codd’s model was originally called Structured English Query
Language (SEQUEL) with the word English letter being dropped
in favour of Structured Query Language (SQL).

4
Introduction to Oracle
• In 1979 a company called Relational Software Inc released the
first commercially available implementation of SQL.

• Relational Software later came to be known as Oracle


Corporation.

• Oracle Corporation is a company that produces the most widely


used Server based, Multi user RDBMS named Oracle

5
Introduction to Structured Query Language
• Structured Query language is a language that provides an interface to
relational database systems.

• SQL was developed by IBM in the 1970s for use in System R and is a de-
facto standard, as well as an ISO and ANSI standard.
• SQL is often pronounced SEQUEL.

• In common usage SQL also encompasses DML (Data Manipulation


Language) for INSERTs, UPDATEs, DELETEs and DDL (Data Definition
Language), used for creating and modifying tables and other database
structures.

• The development of SQL is governed by standards.

• The American National Standard Institute (ANSI) is an organization that


approves certain standards in many different industries.
6
Introduction to Structured Query Language
• SQL has been deemed the standard language in relational
database communication, original approved in 1986 based on
IBM,'s implementation.

• In 1987, the International Standards Organization (ISO)


accepted the ANSI SQL standard as the international standard.

• The standard was revised again in in 1992 and was called SQL-
92.

• The newest standard is now called SQL-99, it is also referred to as


SQL3. SQL3 supports object extensions and are partially
implemented in Oracle 8 and 9.

7
Introduction to Structured Query Language
• When an SQL statement is entered it is stored in a part of
memory called the SQL buffer and remains there until a new
statement is entered.

• SQL* PLUS is an Oracle tool that recognises and submit SQL


statements for execution it contains its own command language.
• Features of SQL
– SQL can be used by a range of users including those with little
or no programming experience
– It is a non-procedural language
– It reduces the amount of time required for creating and
maintaining systems
– It is an English like language

8
Introduction to Structured Query Language
• Features of SQL*PLUS
– SQL*PLUS accepts ad-hoc entries of statements
– Accepts apps SQL input from files
– It provides a line editor for modifying SQL statements
– It controls environmental settings
– It formats query results into basic reports
– It access is local and remote data bases

• SQL*PLUS- It is an extension to SQL. It has been introduced to
eliminate SQL limitations. It has hundreds of SQL commands. SQL
is a subset of SQL*PLUS. It is used for setting up the environment.

• Procedural language SQL (PL*SQL) - It is a programming


language native to Oracle. It supports OOPS. It's a fourth generation
language. 9
Table fundamental
• A table is a database object that holds user data.

• Each column of a table will have a specific data type bound to it.

• Oracle and shows that only data which is identical to the data type
of the column, will be stored within the columns.

10
Oracle Data types
• Data types come in several forms and sizes, allowing the
programmer to create tables suited to the scope of the project.

• The decision made in choosing proper data types greatly influence


the performance of a database, so it is wise to have a detailed
understanding of this concepts.

• Following are the most commonly used data types


– CHAR(size)
– VARCHAR(size) / VARCHAR2(size)
– DATE
– NUMBER(P,S)
– LONG
– RAW / LONG RAW
11
CHAR(size)
• This data type is used to store character strings values of fixed length.

• The size in brackets determines the number of characters the cell can
hold.

• The maximum number of characters (i.e. the size) this data type can hold is
255 characters.

• The data held is right padded with spaces to whatever the length
specified

• For example:
– In case of Name CHAR(60), if the data held in the variable Name is
only 20 characters in length, then the entry will be provided with 40
characters worth of spaces.
12
VARCHAR(size) / VARCHAR2(size)
• This data type is used to store variable length alphanumeric data.
• It is a more flexible form of the CHAR data type.
• The maximum this data type can hold up to 4000 characters.

• One difference between this data type and the CHAR data type is Oracle
compares VARCHAR values using non-padded comparison semantics
i.e. the inserted values will not be padded with spaces.

• It also represents data of type String, yet stores this data in variable
length format.
• VARCHAR can hold 1 to 255 characters.
• VARCHAR is usually a wiser choice than CHAR, due to its variable
length format characteristic.

13
DATE
• This data type is used to represent date and time.
• The standard format is DD-MON-YY as in 21-JUN-04.
• To enter dates other than the standard format, use the appropriate
functions.
• Date-Time stores date in 24-hour format.
• By default, the time in a date field is 12:00:00 am, if no time
portion is specified.
• The default date for a date field is the first day of the current month.
• Valid dates range from January 1, 4712 B.C. to 2 December 31,
4712 A.D.

14
NUMBER(P,S)
• The NUMBER data type is used to store numbers ( fixed or floating
point).
• Numbers of Virtually any magnitude maybe stored upto 38 digits of
precision.
• Valid values are 0, and positive and negative numbers with magnitude
1.0E- 130 to 9.9...E125.
• Numbers may be expressed in two ways: first, with the numbers 0 to 9, the
signs + And -, and a decimal point (.); second, in scientific notation, such
as 1.85E3 for 1850.

• The precision (P), determines the maximum length of the data, whereas
the scale (S), determines the number of places to the right of the decimal.
• If scale is omitted then the default is zero.
• If precision is omitted, values are stored with their original precision upto
the maximum of 38 digits.

15
LONG
• This data type is used to store variable length character strings up to 2GB.
• LONG data can be used to store arrays of binary data in ASCII format.
• Only one LONG value can be defined per table.

• LONG values cannot be used in


– sub queries,
– functions,
– expressions,
– where clauses or indexes and
– the normal character functions such as SUBSTR cannot be applied to LONG
values.

• A table containing a LONG value cannot be clustered. (A cluster is a schema


object that contains data from one or more tables, all of which have one or more
columns in common. Oracle Database stores together all the rows from all the
tables that share the same cluster key.)
16
RAW / LONG RAW
• The RAW / LONG RAW data types are used to store binary data,
such as digitized picture or image.

• Data loaded into columns of these data types are stored without any
further conversion.

• RAW data type can have a maximum length of 255 bytes.

• LONG RAW data type can contain up to 2GB.

• Values stored in columns having LONG RAW data type cannot be


indexed.

17
18
References

• https://docs.oracle.com/cd/B19306_01/server.102/b14200/
statements_5001.htm#:~:text=A%20cluster%20is%20a
%20schema,share%20the%20same%20cluster%20key.&text=Oracle
%20Database%20Performance%20Tuning%20Guide%20for
%20suggestions%20on%20when%20to%20use%20clusters

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

You might also like