DEV Community

Carnato
Carnato

Posted on

Interview Questions of the SQL

What is a trigger? :

  • Trigger is a database object which will automatically invoke or execute when a specific event occur in the database.

  • The most common type of triggers are DML triggers, DDL triggers and Database triggers

  • And this trigger can be invoke before the operation or after the operation.

  • If the function include DML operation like INSERT DELETE UPDATE etc. then it can not be called from the SELECT query. because SELECT query can not change the state of the database.

What is the difference between primary key, unique key and foreign key

PRIMARY KEY

  • When you make a column as primary key. then this column will have a unique value or distinct values. Duplicate and *null value * will not be allow in the column.

  • A table can have only one primary key.

  • Primary key create by one column or group of column.
    UNIQUE KEY :

  • When you make a column as unique key in the table then that table does not have duplicate value. and in unique key null value allow.
    if you talk about the difference b/w the unique and primary key.
    then only one difference, primary key does not allow null value but unique key allow null value.

Difference betwen WHERE and HAVING clause

Discussion (0)