Followers

EXE-13

1]
Create a table with details as given below
Table Name Machine
Columns Column Name    Column Data Type       Constraints
1       Machine_id     integer                Primary key
2       Machine_name   varchar (50)           NOT NULL, uppercase
3       Machine_type   varchar(10)            Type in ( ‘drilling’, ‘milling’,‘lathe’, ‘turning’, ‘grinding’)
4       Machine_price  float                  Greater than zero
5       Machine_cost   float
Table level constraint Machine_cost less than Machine_price
ans.

1]
create table machine(
id integer primary key,
name varchar(50) not null  ,
type varchar(50) check (type in ('drilling', 'milling','lathe', 'turning', 'grinding')),
price float check (price>0),
cost float,
check(name=upper(name))
);
or
create table machine(
id integer primary key,
name varchar(50) not null check(name=upper(name))  ,
type varchar(50) check (type in ('drilling', 'milling','lathe', 'turning', 'grinding')),
price float check (price>0),
cost float

);


insert into machine values(1,'ABC','drilling',22,234);
insert  into machine values(2,'PQR','milling',200,300);

select *from machine;

****************************************
2]
Create a table with details as given below
Table Name Employee
Columns Column Name          Column Data Type   Constraints
1       Employee_id          integer            Primary key
2       Employee_name        varchar (50)       NOT NULL, uppercase
3       Employee_desg        varchar(10)        Designation in ( ‘Manager’,‘staff’, ‘worker’)
4       Employee_sal         float              Greater than zero
5       Employee_uid         text               Unique
Table level constraint Employee_uid not equal to Employee_id

ans.

create table employee(
id integer primary key,
name varchar(50) not null check(name=upper(name)),
desg varchar(10) check(desg in ('Manager','staff', 'worker')),
sal float check (sal>0),
uid text unique

);

No comments:

Post a Comment

EXE -11 To create simple tables , with only the primary key constraint ( as a table level constraint & as a field level constraint) (include all data types)

Create database: 1  -  Create a table with details as given below  Table Name=> PLAYER Columns Column Name ...