Skip to main content

Posts

Showing posts with the label DBMS

Drop Command (DDL) in SQL Oracle With Implementation

 Drop Command (DDL) in SQL Oracle With Implementation For Explanation Watch Video:: Drop Command Used to delete  table (rows X columns) EX::: 1)Create table SQL> create table emp01(fname varchar2(15),sal Number(10)); Table created. 2)Describe table SQL> desc emp01;  Name                                      Null?    Type  ----------------------------------------- -------- ----------------------------  FNAME                                              VARCHAR2(15)  SAL                                                NUMBER(10) SQL> select * from emp01; no rows selected 3)Insert values into table SQL> insert into ...

Truncate Command (DDL) in SQL Oracle With Implementation

 Truncate Command (DDL) in SQL Oracle With Implementation For Explanation Watch Video:: Truncate:    -TO delete all rows from table at a time    - Deleting rows but not column    - By using this cmd we cant delete specific row from table    -It doesnt support where clause EX::: SQL> create table emp01(fname varchar2(10),sal Number(10)); Table created. SQL> insert into empo1 values('miller',500000); insert into empo1 values('miller',500000)             * ERROR at line 1: ORA-00942: table or view does not exist SQL> insert into emp01 values('miller',500000); 1 row created. SQL> insert into emp01 values('Baburao',50000); 1 row created. SQL> insert into emp01 values('Smith',500000); 1 row created. SQL> select * from emp01; FNAME             SAL ---------- ---------- miller         500000 Baburao         50000 Smith...

Primary Key Constraint In SQL

 Primary Key::constraint ======================  ->It is combination of Unique and not null ->Restricted Duplicates and Nulls ->A table is having Only one primary Key At column Level:: ================= EX:: SQL> create table test2(eid int primary key,ename varchar2(10) primary key); create table test2(eid int primary key,ename varchar2(10) primary key)                                                           * ERROR at line 1: ORA-02260: table can have only one primary key SQL> create table test2(eid int primary key,ename varchar2(10)); Table created. SQL> insert into test2 values(1,'sam'); 1 row created. SQL> insert into test2 values(2,'dan'); 1 row created. SQL> select * from test2;        EID ENAME ---------- ----------          1 sam        ...

Check Constraints In SQL

  Check Constraint::   ->to check values before accepting into a column with user defined condition at column level:: ================ >create table test1(eid int check(eid<5),ename varchar2(10)); EX:: SQL> create table test1(eid int check(eid<5),ename varchar2(10)); Table created. SQL> insert into test1 values(1,'dan'); 1 row created. SQL> insert into test1 values(2,'sam'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------          1 dan          2 sam SQL> insert into test1 values(5,'sam'); insert into test1 values(5,'sam') * ERROR at line 1: ORA-02290: check constraint (SYSTEM.SYS_C007650) violated SQL> insert into test1 values(4,'sam'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------          1 dan          2 sam         ...

Not Null Constraint In SQL

 Not Null Constraint: ====================   -Restricted nulls but accepting duplicates      -Not null an not be applied at table level ex:: create table test1(eid int not null,ename varchar2(10) not null); EX:: SQL> create table test1(eid int not null,ename varchar2(10) not null); Table created. SQL> insert into test1 values(10,'raja'); 1 row created. SQL> insert into test1 values(20,'dan'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------         10 raja         20 dan SQL> insert into test1 values(null,'dan'); insert into test1 values(null,'dan')                          * ERROR at line 1: ORA-01400: cannot insert NULL into ("SYSTEM"."TEST1"."EID") SQL> insert into test1 values(10,null); insert into test1 values(10,null)                   ...

unique constraint in sql

Unique Constraint:: ================  -Restricted Duplicates values but accepting nulls into a column column level:: ============ >create table test1(sno int unique,name varchar2(10) unique); EX:: SQL> create table test1(eid int unique,ename varchar2(10) unique); Table created. SQL> insert into test1 values(10,'virat'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------         10 virat SQL> insert into test1 values(10,'rohit'); insert into test1 values(10,'rohit') * ERROR at line 1: ORA-00001: unique constraint (SYSTEM.SYS_C007643) violated SQL> insert into test1 values(20,'virat'); insert into test1 values(20,'virat') * ERROR at line 1: ORA-00001: unique constraint (SYSTEM.SYS_C007644) violated SQL> insert into test1 values(20,'rohit'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------         10 virat     ...