This tutorial will help you to learn the uses of major data types in Oracle.
Example-1: Use of char, varchar2 and Date data types
Create a table named members that consists of 5 fields, acc_id, acc_name, acc_type, acc_nid, acc_create_date. acc_id and acc_nid char and other fields are varchar.
CREATE TABLE members (
acc_id CHAR(10),
acc_name VARCHAR2(50),
acc_type VARCHAR2(7),
acc_nid CHAR(13),
acc_create_date DATE,
CONSTRAINT member_pk PRIMARY KEY(acc_id));
Insert a new row into the table.
INSERT INTO members(acc_id, acc_name, acc_type, acc_nid,acc_create_date )
VALUES('DH76456654', 'Abir Hossain', 'Saving', '6665657787978', '11-NOV-18');
Example-2: Use of float and double
create a table named balance that consists of 5 fields, acc_id, acc_name, acc_type, acc_nid, acc_create_date. acc_id and acc_nid char and other fields are varchar.
CREATE TABLE balance (
mem_id CHAR(10),
interest float,
balance NUMBER(8,2),
CONSTRAINT balance_pk PRIMARY KEY(mem_id));
Insert a new row into the table.
INSERT INTO balance(mem_id, interest, balance)
VALUES('DH76456654', 785555555, 8776555.89);
This record will not be inserted because the value of the balance field exceeds the data type limit of this field.
Exercise: Suppose you have to store data of a TV company. Design a table with char, varchar2, date, and float to store the details of all TV of that company.