

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A concise overview of data definition language (ddl) commands in sql, focusing on enforcing integrity constraints. It includes examples of creating, altering, renaming, truncating, and dropping tables. The document illustrates how to define primary keys, check constraints, unique constraints, and default constraints. It also demonstrates how to insert values into tables and handle constraint violations, making it a useful resource for understanding basic database operations and data integrity in sql. Suitable for high school students and lifelong learners interested in database management and sql.
Typology: Schemes and Mind Maps
1 / 3
This page cannot be seen from the preview
Don't miss anything!


1. Creation of accounts table: SQL> create table accounts (acno number(5) primary key, name varchar2(50), address varchar2(50) not null, city varchar2(50) check(city in('hyd','chennai','bangalore')), pincode number(6) default 000000, state varchar2(50), dob date, doj date default sysdate, phone number(10) unique, balance number(10) check(balance>500)); Table created. Insertion of values into table: - SQL> insert into accounts values(10001,'susmit','sangareddy','hyd',502313,'telangana','11-aug- 2005','21-mar-2025',7416796685,50000); 1 row created. - SQL> insert into accounts values(10002,'aryan','bowenpally','hyd',503515,'telangana','28-sep- 2005','21-mar-2025',8247586600,50000); 1 row created. Check constraint violation: - SQL> insert into accounts values(10001,'susmit','sangareddy','vizag',502313,'telangana','11-aug- 2005','21-mar-2025',7416796685,50000); insert into accounts values(10001,'susmit','sangareddy','vizag',502313,'telangana','11-aug-2005','21- mar-2025',7416796685,50000)
ERROR at line 1:
ORA-02290: check constraint (SYSTEM.SYS_C004500) violated
ERROR at line 1: ORA-02290: check constraint (SYSTEM.SYS_C004501) violated Unique constraint violation: SQL> insert into accounts values(10002,'aryan','bowenpally','hyd',503515,'telangana','28-sep-2005','21mar- 2025',7416796685,50000); insert into accounts values(10002,'aryan','bowenpally','hyd',503515,'telangana','28-sep-2005','21mar- 2025',7416796685,50000)
ERROR at line 1: ORA-00001: unique constraint (SYSTEM.SYS_C004503) violated Default constraint violation: insert into accounts values(10001,'susmit','sangareddy','hyd',502313,'telangana','11-aug- 2005','21mar-2025',7416796685,50000);
ERROR at line 1: