DBMS PRG3 LAB
DBMS PRG3 LAB
VIEWS
DATE :
AIM:
To implement the database using SQL Data definition with constraints, Views
.
Creation, Altering and Dropping of Tables and Inserting Rows into a Table (Use Constraints
While Creating Tables).
DATA TYPES:-
SQL supports following types of data types.
CHAR (SIZE):-
The CHAR data type stores fixed-length character strings.
When you create a table with a CHAR column, you must specify a string length (in bytes or characters)
between 1 and 2000 bytes for the CHAR column width. The default is 1 byte.
VARCHAR (SIZE):-
The VARCHAR data type is synonymous with the VARCHAR2 data type.
NUMBER (L):-
The NUMBER datatype stores fixed and floating-point numbers. Numbers of virtually any magnitude
can be stored and are guaranteed portable among different systems operating Oracle Database, up to 38
digits of precision.
DATE:-
The DATE datatype stores point-in-time values (dates and times) in a table. The DATE datatype stores
the year (including the century), the month, the day, the hours, the Minutes, and the seconds (after
midnight).
LONG:-
Character data of variable length which stores up to 2 Gigabytes of data. (A bigger
version the VARCHAR2 datatype).
INTEGER:-
Integer type of Data. It is actually a synonym for NUMBER(38)
FLOAT:-
FLOAT is a 32-bit, single-precision floating-point number datatype. Each FLOAT 8 value requires 5
bytes, including a length byte.
DOUBLE:-
DOUBLE is a 64-bit, double-precision floating-point number datatype. Each DOUBLE value requires 9
bytes, including a length byte.
Data Definition Language (DDL) Commands: -
Create Table
SQL> CREATE TABLE users (id INT NOT NULL AUTO_INCREMENT, name VARCHAR (50)
NOT NULL, age INT NOT NULL, PRIMARY KEY (id));
2. Add a new column gender with not null constraints to the existing table students
SQL> ALTER TABLE users ADD gender VARCHAR(10) NOT NULL AFTER AGE;
Table altered.
ALTER TABLE users ADD city VARCHAR (50) NOT NULL, ADD contact VARCHAR (50) NOT
NULL;
SQL> DESC students;
3. All constraints and views that reference the column are dropped automatically, along
With the column.
7. Delete Table
Table deleted.
RESULT:
The DDL commands have been executed successfully