- What is SQL ?
SQL is Structured Query Language . This is a standard language used to perform tasks such as INSERT/UPDATE/DELETE and SELECT of data from a database. - What is Database ?
Database is nothing but an organized form of data for easy access, storing, retrieval and managing of data. - Constraints in SQL ?
NOT NULL – Restricts NULL value from being inserted into a column.
CHECK – Verifies that all values in a field satisfy a condition.
DEFAULT – Automatically assigns a default value if no value has been specified for the field.
UNIQUE – Ensures unique values to be inserted into the field.
INDEX – Indexes a field providing faster retrieval of records.
PRIMARY KEY – Uniquely identifies each record in a table.
FOREIGN KEY – Ensures referential integrity for a record in another table. - Difference Between Primary Key and Foreign Key ?
A Primary key is nothing but unique column in Table and in each table we can have one single Primary Key.
A FOREIGN KEY comprises of single or collection of fields in a table that essentially refer to the PRIMARY KEY in another table. Foreign key constraint ensures referential integrity in the relation between two tables. - What is a JOINS ? and How Many Types ?
JOIN is nothing but combining the records of two or more tables.
INNER JOIN : Matching the Table A and Table B Data.
LEFT JOIN : Retrieving the Data if not matched with Table B.
RIGHT JOIN : Retrieving the Data if not matched with Table A.
FULL JOIN : Retrieving the Data if not matched or Unmatched with Table A and Table B. - What is Difference between Clustered and Non Clustered Index ?
Clustered Index : Clustered index is used for easy retrieval of data from the database and its faster whereas reading from non clustered index is relatively slower.
Clustered index alters the way records are stored in a database as it sorts out rows by the column which is set to be clustered index whereas in a non clustered index, it does not alter the way it was stored but it creates a separate object within a table which points back to the original table rows after searching.
One table can only have one clustered index whereas it can have many non clustered index. - What is Normalization?
Normalization is the process of organizing data to avoid duplication and redundancy. Some of the advantages are:
Better Database organization
More Tables with smaller rows
Efficient data access
Greater Flexibility for Queries
Allows easy modification
More Compact Database - Difference between DROP and TRUNCATE ?
DROP command removes a table and it cannot be rolled back from the database whereas TRUNCATE command removes all the rows from the table. - What is Trigger ?
Trigger in SQL is are a special type of stored procedures that are defined to execute automatically in place or after data modifications. It allows you to execute a batch of code when an insert, update or any other query is executed against a specific table. - What is View ?
A view is a virtual table which consists of a subset of data contained in a table. Since views are not present, it takes less space to store. View can have data of one or more tables combined and it depends on the relationship.