DB Lab 03
DB Lab 03
DATABASE
SUBMITTED TO:
Sir Adeel
BATCH:
BCS-IV(A)
DATE OF SUBMISSION:
February 19, 2021.
LAB 03:
A datatype 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 datatype
differently from values of another datatype. For example, Oracle can add values of NUMBER datatype, but
not values of RAW datatype.
Oracle supplies the following built-in datatypes:
Character datatypes
CHAR
NCHAR
VARCHAR2 and VARCHAR
NVARCHAR2
CLOB
NCLOB
LONG
Numeric datatypes
NUMBER
Time and date datatypes:
DATE
INTERVAL DAY TO SECOND
INTERVAL YEAR TO MONTH
TIMESTAMP
TIMESTAMP WITH TIME ZONE
TIMESTAMP WITH LOCAL TIME ZONE
Binary datatypes
BLOB
BFILE
RAW
LONG RAW
Creating Tables in Oracle
Once you have designed the table and decided about datatypes use the following SQL
command to create a table.
For example, the following statement creates a table named Emp.
CREATE TABLE Emp (
Empno NUMBER(5),
Ename VARCHAR2(15),
Hiredate DATE,
Sal NUMBER(7,2)
);
To insert rows in the table you can use SQL INSERT command.
For example the following statement creates a row in the above table.
To insert rows continuously in SQL Plus you can give the following command.
SQL> insert into emp values (&empno,’&name’,&sal);
These &Empno, &name and &sal are known as substitution variables. That is SQLPlus will
prompt you for these values and then rewrites the statement with supplied values.
To see the rows you have inserted give the following command.
SQL> Select * from emp;
To see the structure of the table i.e. column names and their datatypes and widths. Give the following
command.
SQL> desc emp
To see how many tables are in your schema give the following command.
SQL> select * from cat;
or
SQL> select * from tab;
TASKS