SQL Data Types
Date and Time Types in SQL :
Date : A calendar date containing a four-digit year, month and day of the month.
date ‘2001-04-25’
Time : The time of the day in hours, minutes and seconds.
time ’09:30:00’
Timestamp : the mixture of date and time.
timestamp ‘2001-04-25 10:29:01’
Note : SQL defines several functions to get the current_date and current_time.‘interval’ is another data type provided by SQL.
Default Values :
SQL allows a default value to be specified for an attribute.
Example-1 :
Create table student (ID varchar2(5), Name varchar2(20) not null, DNo varchar2(10), Tot_cred number(3) default 0, Primary key (ID) ) ;
Index Creation :
An index on an attribute of a relation may be an arrangement that permits the database system to seek out those tuples within the relation that have a specified value for that attribute, effectively, without traversing every tuple of the relation.
Example-2:
create index Faculty_Dept_index on faculty (dept) ;
This statement generates an index named ‘Faculty_Dept_index’ on the attribute dept of the relation faculty.