Labwork DBMS
Labwork DBMS
Renaming a Table:
Using OR:
Syntax- SQL> select * from Table_name where column_name =value OR column_name2 like ‘_%’;
Using AND:
Syntax- SQL> select * from Table_name where column_name =value AND column_name2 like ‘_%’;
Using Between:
Aggregate Function- An SQL aggregate func on calculates a set of values and returns a single
value. For example, an average func on (AVG) takes a list of values and returns the average.
Revoking Permission
ASSIGNMENT-6
A Primary key is a unique column we set in a table to easily identify and locate data in
queries. A table can have only one primary key.
The primary key column has a unique value and doesn’t store repeating values. A Primary
key can never take NULL values. For example, in the case of a student when identification
needs to be done in the class, the roll number of the student plays the role of Primary key.
Syntax:
CREATE TABLE tableName (
col1 int NOT NULL,
col2 varchar(50) NOT NULL,
col3 int,
…………….
PRIMARY KEY (col1)
);
A Foreign key is beneficial when we connect two or more tables so that data from both
can be used parallelly. The table which contains the foreign key is often called the child table,
and the table whose primary key is being referred by the foreign key is called the Parent
Table.
Syntax:
CREATE TABLE childTable (
col1 int NOT NULL,
col2 int NOT NULL,
col3 int,
………...
PRIMARY KEY (col1),
FOREIGN KEY (col3) REFERENCES parentTable(parent_Primary_key)
);