You are on page 1of 8

Experiment No.

06

Create Index, Drop Index statements, Drop Table, Truncate Table,


Alter Table, DESC statement, Update and Delete queries.
Objectives:

 Know about SQL/Oracle Commands for different functions.


 Hands on practice and concepts on SQL commands.

Apparatus:
Hardware: Workstation (PC)
Software: Oracle Express Edition 11g
Procedure:
Turn on PC, Open the tool Oracle Express Edition 11g and start practice.
Safety precautions:

 Stay away from electric equipment

Procedure:
Turn on PC, Open the tool Oracle Express Edition 11g and start practice.
Safety precautions:
Stay away from electric equipment.

SQL commands:
Create a table .After entering the values in a table, Let the table is:

Create Index:
Drop Index:

Drop table:
The DROP table command deletes a table in the database.

Truncate a table:
The TRUNCATE table command deletes the data inside a table, but not the table itself.

Alter Table:

After this query,table is:

Desc statement:

Result after executing this query:


Update Queries:
The UPDATE statement is used to modify the existing records in a table.

Result after executing this query:

Delete Queries:

Result:

Conclusion:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________
Remarks:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________

Experiment No. 07

SQL/Oracle Data Types


Objectives:

 Know about SQL/Oracle Data types.


 Hands on practice and concepts on SQL data types.

Apparatus:
Hardware: Workstation (PC)
Software: Oracle Express Edition 11g
Procedure:
Turn on PC, Open the tool Oracle Express Edition 11g and start practice.
Safety precautions:

 Stay away from electric equipment

Data Types in Oracle:


A data type associates a fixed set of properties with the values that can be used in a
column of a table or in an argument of a procedure or function. These properties cause
Oracle to treat values of one data type differently from values of another data type; for
example, Oracle can add values of NUMBER data type but not values of RAW data
type.
Oracle supplies the following built-in data types:
1. Character data type
Character data types are as follows:
 CHAR
 NCHAR
 VARCHAR2 and VARCHAR
 NVARCHAR2
 CLOB
 NCLOB
 LONG

Data type Description Size


CHAR Fixed-length character Maximum size is 2000 bytes
data of length size bytes. per row, default size is 1 byte
per row.
NCHAR Fixed-length character Maximum size is determined
data of by the number of bytes
length size characters or required to store one character,
bytes, depending on the with an upper limit of 2000
national character set. bytes per row.
VARCHAR2 Variable-length character Variable for each row, up to
data. 4000 bytes per row.
NVARCHAR2 Variable-length character Maximum size is determined
data of by the number of bytes
length size characters or required to store one character,
bytes, depending on with an upper limit of 4000
national character set. A bytes per row.
maximum size must be
specified.
CLOB Single-byte character Up to 2^32 - 1 bytes, or 4
data. gigabytes.

NCLOB Single-byte or fixed- Up to 2^32 - 1 bytes, or 4


length multi byte national gigabytes.
character set (NCHAR)
data.
LONG Variable-length character Variable for each row in the
data. table, up to 2^31 - 1 bytes, or 2
gigabytes, per row.
2. Number data type:
Number (p, s) is a variable-length numeric data. Maximum precision p
scale s is 38. The maximum space required for a given column is 21 bytes per
row.
3. Date data type:
Fixed-length date and time data, ranging from Jan. 1, 4712 B.C.E. to Dec. 31,
4712 C.E.  Fixed at 7 bytes for each row in the table. Default format is a string
(such as DD-MON-YY) specified by NLS_DATE_FORMAT parameter.

4. Binary data type:


Binary data type are as follows:
 BLOB
 BFILE
 RAW (size)
 LONG RAW
 ROWID

Data Description Size


type
BLOB Unstructured binary Up to 2^32 - 1 bytes, or 4 gigabytes.
data.
BFILE Binary data stored in Up to 2^32 - 1 bytes, or 4 gigabytes.
an external file.
RAW Variable-length raw Variable for each row in the table, up to
(size) binary data. 2000 bytes per row. A
maximum size must be specified.
Provided for backward compatibility.
LONG Variable-length raw Variable for each row in the table, up to
RAW binary data. 2^31 - 1 bytes, or 2 gigabytes, per row.
Provided for backward compatibility.
ROWID Binary data Fixed at 10 bytes (extended ROWID)
representing row or 6 bytes (restricted ROWID) for each
addresses. row in the table.

5. Misc Data Types:

Data type Description


sql_variant Stores values of various SQL Server-supported
data types, except text, ntext, and timestamp.

timestamp Stores a database-wide unique number that gets


updated every time a row gets updated
uniqueidentifier Stores a globally unique identifier(GUID)
xml Stores XML data. You can store xml instances in
a column or a variable
cursor Reference to a cursor object
table Stores a result set for later processing

EXAMPLE:

 In the query given above ID (INT) and salary (DECIMAL) are exact
Numeric Data types.
 Name and address are of Character strings data type.
 Cdate is included in date and time data types.

Conclusion:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________
Remarks:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________

You might also like