6-Inserting _ Updating _ Deleting Records in a Table - Using Transaction Control Commands-29!01!2024
6-Inserting _ Updating _ Deleting Records in a Table - Using Transaction Control Commands-29!01!2024
username: 22BIT0025@SITEORA
password: 22BIT0025
SQL>password
Relational database
create
alter command
insert
update
delete
Minit char(1),
Sex char(1),
Address varchar(100),
salary number(10),
DOB date,
Department number(1),
designation varchar(20),
SupervisorSSN char(9)
);
create table Department (Dnumber number(1) primary key,
ManagerSSN char(9),
Manager_DOB date,
Location varchar(60)
);
A table can have at the most one primary key; but it can have multiple secondary keys.
DOB date,
Sex char,
Relationship varchar(30),
EmployeeSSN char(9),
);
Name varchar(20),
Location varchar(40),
ControllingDepartment number(1),
Budget number(20)
);
ProjectNum number(2),
);
***********
insert into employee1 values (&SSN, &fname, &Minit, &Lname, &Sex, &Address, &salary, &DOB,
&Department, &designation, &SupervisorSSN);
commit;
To see the data that you have entered into the table use
SQL>@file-path
Data entry
***********
insert into employee values (&SSN, &fname, &Minit, &Lname, &Sex, &Address, &salary, &DOB,
&Department, &designation, &SupervisorSSN);
Constraint definition
==================
alter table department add [constriant dept_chk] check (dnumber between 1 and 9);
Foreign key:
A foreign key is a column that appears as a key column in some other table.
The domain of foreign key column must be the same as that of the referencing column (key column it
refers to).
The data type along with size (may be not null also) defines domain of a column.
ALTER TABLE table_name ADD FOREIGN KEY (col1, col2,...) REFERENCES other_table_name(col1,
col2, ...);
Check constraint
===============
ii) Relationship of the dependents to an employee should be only Spouse, Son, Daughter, and Parent.
alter table dependent12 add check (relationship in ('Spouse', 'Son', 'Daughter', 'Parent') );