Sunday , October 20 2019
Home / SQL

SQL

Definition of FOREIGN KEY constraint

Database-Relationship

The FOREIGN KEY constraint is used to enforce referential integrity in the oracle database. The basic concept about FOREIGN KEY constraint is that “the values of a table (parent table) must store in another table (child table)”. By the FOREIGN KEY constraint, we can build relationship between two or more …

Read More »

Add PRIMARY KEY constraint on Existing Table by ALTER TABLE statement

Database-Relationship

You can define PRIMARY KEY constraint on existing table by ALTER TABLE statement. Practice: This practice will cover how to define PRIMARY KEY constraint on a column after creating a table by ALTER TABLE statement. Syntax: ALTER   TABLE   table_name   ADD   CONSTRAINT pk_constraint_name  PRIMARY KEY (primary_key_column_name); Here …

Read More »

Set UNIQUE constraint ignoring duplicate data in Oracle

Unique Constraint

When we create constraints in oracle, by default, the constraint exists in NON DEFERRABLE and VALIDATE state. So, by default, oracle checks each time for unique data when we insert or update data. You can create constraint as DEFERRABLE and NOVALIDATE state. In the situation, oracle will not check existing …

Read More »

Set UNIQUE constraint by ALTER TABLE statement in Oracle

Unique Constraint

You can define UNIQUE constraint after creating table by ALTER TABLE statement. Practice: This practice will cover how to set UNIQUE constraint on an existing table column by ALTER TABLE statement. Syntax: ALTER   TABLE   table_name   ADD   CONSTRAINT uk_constraint_name  UNIQUE  (unique_column_name); Here unique_column_name is the name of …

Read More »

Set NOT NULL constraint by ALTER TABLE statement in Oracle

You can set NOT NULL constraint on existing table column by ALTER TABLE statement. Practice: This practice will cover to set the NOT NULL constraint in existing table by ALTER TABLE statement. To continue the practice, the steps should be followed. Step-1: First drop the REGISTRTION table if already created  …

Read More »

Set NOT NULL constraint by CREATE TABLE statement in Oracle

Definition of NOT NULL constraint: The NOT NULL constraint is used to restrict null values to be inserted in table column. By default, oracle allows null values to be inserted in column of a table. But if you want to prohibit null values, you have to set NOT NULL constraint …

Read More »

Definition and Types of SQL Constraints in Oracle

Constraint is a specific rule to data. The rule restricts data to be inserted or updated into the table in oracle database. Data must be conformed the rule before inserting and updating into table. So, constraint is used to set specific rules on column of a table. When we insert …

Read More »