SQL Commands 4
SQL Commands 4
Every database has tables, and constraints cannot be referred to as a rational database
system. And if any database has only relational data model, it cannot be a Relational
Database System (RDBMS). So, some rules define a database to be the correct
RDBMS. These rules were developed by Dr. Edgar F. Codd (E.F. Codd) in 1985, who
has vast research knowledge on the Relational Model of database Systems. Codd
presents his 13 rules for a database to test the concept of DBMS against his relational
model, and if a database follows the rule, it is called a true relational database
(RDBMS). These 13 rules are popular in RDBMS, known as Codd's 12 rules.
foreign key
In the relational databases, a foreign key is a field or a column that is used to establish
a link between two tables.
In simple words you can say that, a foreign key in one table used to point primary key
in another table.
Here are two tables first one is students table and second is orders table.
STUDENT table:
ORDER table:
O_Id OrderNo S_Id
1 99586465 2
2 78466588 2
3 22354846 3
4 57698656 1
Here you see that "S_Id" column in the "Order" table points to the "S_Id" column in
"Students" table.
o The "S_Id" column in the "Student" table is the PRIMARY KEY in the "Student"
table.
o The "S_Id" column in the "Order" table is a FOREIGN KEY in the "Order" table.
The foreign key constraint is generally prevents action that destroy links between
tables.
Primary key cannot be null on the other hand foreign key can be null.
Primary key uniquely identify a record in a table while foreign key is a field in a table
that is primary key in another table.
There is only one primary key in the table on the other hand we can have more than
one foreign key in the table.
UNION operator
The following query shows all records of both tables in one table using the UNION
operator:
Output:
INSTR_P_Position
CONCAT
Output:
'JAVATPOINT'
1. SELECT LTRIM( 'NEW DELHI IS THE CAPITAL OF INDIA', 'NEW DELHI IS THE ');
Output:
CAPITAL OF INDIA
Example 4: The following SELECT query trims the given symbol from the specified
string:
Output:
98221545###
The following SELECT query truncates the given space from the specified string
according to the RTRIM function:
Output:
'JAVATPOINT'
Example 2: The following SELECT query truncates the space from the specified
string according to the RTRIM function:
Output:
' JAVATPOINT'
Output:
UPPER