Database Reference
In-Depth Information
Column Name Data Type Size RollNo Number 4
Semester Number 1
Marksobt Number 4
Maxmarks Number 4
Remarks Character 15
Sol:
CREATE TABLE Student_result
(
Rollno number(4) ,
Semester number(1) , Marksobt number(4) , Maxmarks number(4) , Remarks char(15));
Creating table with Primary Key or NULL values
A constraint is an option that further defines a table or a column. It will either add more in-
formation to or put certain restrictions on the table or column. The first constraint is NULL
or NOT NULL. This allows you to specify whether or not a column accepts NULL values.
If a column is defined as NOT NULL, some value has to be assigned to that column or
else the database will produce an error. There are also constraints available that will define
primary keys and foreign key relationships. Using these while creating tables will enable
your database to enforce referential integrity. Using the PRIMARY KEY constraint after a
column will designate that column, and that column alone, as the primary key.
Example : Create a table Staff with Primary Key and NULL values:
Sol:
CREATE TABLE Staff
(
StaffID
Name
DOB
Designation Department Address
City
Phone
);
number(4)
varchar2(20) date
Search WWH ::




Custom Search