Let us see our SQL script in the previous tutorial for creating table ‘employee’ :
create table employee(
id integer not null,
name varchar(30) not null,
age integer not null,
phonenumber varchar(12) not null)
We have an integer data type for column ‘id’ and ‘age’. As we know integer has range value between -2,147,483,648 to 2,147,483,647. We can insert a negative value to these columns. But in the real world, id and age can not have a negative value.
We can solve this problem by creating a DOMAIN. DOMAIN is a customized column definition.
The syntax to create a domain is :
CREATE DOMAIN domain_name AS data type
DEFAULT devault_value NOT NULL
CHECK (condition)
DEFAULT clause and CHECK clause are optional.
Type the codes below in the text editor, and save it with file name ‘mydata_domain.txt’.
create database 'c:\mydata\mydata.gdb'
user 'NEW_USER' password 'password';
create domain string30 as varchar(30);
create domain string12 as varchar(12);
create domain domain_id as integer check(value>0);
create domain domain_age as integer
check(value>18 and value<55);
Go to InterBase Interactive SQL window.
You can not run the script above, because database 'c:\mydata\mydata.gdb' is slready exist. You need to drop the old database first.
Go to Previous Tutorial or NextTutorial
I like this article very much because it is technical and very much useful for me to gather more knowledge. Good to read...
ReplyDeletedomain name India
We should thank you for giving such a wonderful blog. Your site happens to be not only informative but also very imaginative too. We find a limited number of experts who can think to write technical articles that creatively. Website Domain Name
ReplyDeletes The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
ReplyDelete