Sunteți pe pagina 1din 3

CREATE TABLE branch_mstr

2 ( Branch_No Varchar2(10) Constraint Branchno_NN NOT NULL,


3 Name Varchar2(20) Constraint Name_NN NOT NULL
4 )
5 /

Table created.

SQL> desc branch_mstr


Name Null? Type
------------------------------- -------- ----
BRANCH_NO NOT NULL VARCHAR2(10)
NAME NOT NULL VARCHAR2(20)

SQL> insert into branch_mstr values(1001,'SRNAG');

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into branch_mstr values(1001,'NULL')


SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

1* insert into branch_mstr values(1001,NULL)


2 /
insert into branch_mstr values(1001,NULL)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("JONES"."BRANCH_MSTR"."NAME")

SQL> ed
Wrote file afiedt.buf

1* insert into branch_mstr(name) values('APET')


2 /
insert into branch_mstr(name) values('APET')
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("JONES"."BRANCH_MSTR"."BRANCH_NO")

SQL> ed
Wrote file afiedt.buf

1* insert into branch_mstr(name) values('APET')


2
SQL>
SQL> select *from branch_mstr;

BRANCH_NO NAME
---------- --------------------
1001 SRNAG
1001 NULL

SQL> select constraint_name,constraint_type


2 from user_constraints
3 where table_name='branch_mstr
4
SQL>
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,constraint_type
2 from user_constraints
3* where table_name='branch_mstr'
4 /

no rows selected

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,constraint_type
2 from user_constraints
3* where table_name='BRANCH_MSTR'
SQL> /

CONSTRAINT_NAME C
------------------------------ -
BRANCHNO_NN C
NAME_NN C

SQL> ed
Wrote file afiedt.buf

1 select constraint_name,constraint_type
2 from user_constraints
3* where table_name='BRANCH_MSTR'
4
SQL>
SQL> ed
Wrote file afiedt.buf

1 select constraint_name,column_name
2 from user_cons_columns
3* where table_name='BRANCH_MSTR'
4 /

CONSTRAINT_NAME
------------------------------
COLUMN_NAME
-----------------------------------------------------------------------------
-----------------------
BRANCHNO_NN
BRANCH_NO

NAME_NN
NAME

SQL> clear screen


SQL> /

CONSTRAINT_NAME
------------------------------
COLUMN_NAME
-----------------------------------------------------------------------------
-----------------------
BRANCHNO_NN
BRANCH_NO

NAME_NN
NAME

SQL>

S-ar putea să vă placă și