SQL Interview Questions
SQL Interview Questions
SQL Interview Question for Freshers
What is sql ?
SQL (Structure Query Language) is a non-procedural language. SQL are used for access and manipulate data in databases. SQL is an ANSI (American National Standards Institute) standard language.
What is Rdbms ?
All modern database management systems like SQL, MS SQL Server, IBM DB2, Oracle, My-SQL and Microsoft Access are based on Rdbms.
Rdbms was developed by a jermen scientice mr. E.F codd at 1970 this model was developed on the basis of a mathematical concept called relational algebra.
Why need of SQL ?
SQL is required for perform following operation on database
- To create new databases, tables.
- To insert any records in database
- To update records in database
- To delete records from database
- To retrieve data from database
Explain feature of sql ?
- SQL is not a case sensitive language.
- Every commands in SQL should ends with semicolon(;).
- SQL can also called as sequel (SEQUEL).
Sql is case sensitive languale ?
SQL is not a case sensitive language.
How many constraints in sql ?
- Unique key
- Not NUll
- Primary key
- Check
- Foreign key
- Default
Why use semicolon after SQL statements ?
Semicolon is used to separate SQL statements. It is a standard way to separate SQL statements in a database system in which more than one SQL statements are used in the same call.
What is table ?
Rdbms are use table to store data, table are the collection of related data entries and row and column.
What is Field ?
Field is a smaller entity of the table which contains specific information about every record in the table.
What is row ?
Row is a part of table which is horizontally disply in table it is also called record. Row contains the specific information of each individual entry in the table.
What is column ?
A column is a vertical entity in the table which contains all information associated with a specific field in a table.
What is cell ?
A cell is a place where you can store your data.
What are DDL commands ?
Data Definition Language(DML) statements are used to define data structures in database. All DDL command are given below;
- Drop
- Create
- Alter
- Rename
- Truncate
What are DML command ?
DML Command Data Manipulation Language(DML) statements are used for manipulating data in database. All DML commanda are given below;
- Select
- Insert
- Update
- Delete
What are DCL command ?
Data Control Language(DCL) are used to control access to data stored in a database. You can say in database language DCL are used to control privilege in database.
- Grant: to allow specified users to perform specified tasks.
- Revoke: to cancel previously granted or denied permissions.
What are TCL command ?
Transaction Control Language (TCL) Command are used to manage transaction in database.
- commit
- rollback
- savepoint
Difference between trancate and delete
Trancate | Delete | |
---|---|---|
1 | It is DDL Command | It is DML Command |
2 | It is used for permanent deletion. | It is used for temporary deletion. |
3 | We can not delete the specific record. | We can delete the specific records. |
What are set operators in SQL ?
Union, intersect or minus all these operators are called set operators.
Constraint in SQL
What is a constraint ?
Constraints is a mechanism which is used to stop or Restrict invalid data which is entered by the end user.
Where constraints are apply ?
We can apply the constraints in two level on the table.
- Column level constraints
- Table level constraints
What is column level constraints ?
Applying the constraints after defined the column immediately than those constraints called as column level constraints.
What is table level constraint ?
Applying the constraints after defined all the column of the table or end the table if apply the constraints than these constraints called as table level constraints.
What is Primary Key constraints ?
Primary Key Constraints does not allow to enter duplicate as well as null values. This constraints is used to uniquely identify the record. You can not apply Primary Key constraints on more than one column in same table.
What is Forgein Key constraints ?
Using Foreign Key Constraints you can maintain some relation between the two table in the database. Read more......
What is Check constraints ?
Check Constraints does not allow the values which are not satisfied the given condition. You can apply Check constraints on more than one column in same table. Check constraints allows to enter null values.
What is Unique constraints ?
Unique Constraints does not allow duplicate values. You can apply unique constraints on more than one column in same table. You can apply unique constraints on more than one column in same table.
What is Not null constraints ?
Not null Constraints does not allow to enter null value on a particular column in a table. You can apply not null constraints on more than one column in same table.
What is Default Constraints ?
Default Constraints is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified.
What is ACID properties ?
Every transaction follows some transaction properties these are called ACID properties.
Atomicity: Atomicity of a transaction is nothing but in a transaction either all operations can be done or all operation can be undone, but some operations are done and some operation are undone should not occur.
Consistency: Consistency means, after a transaction completed with successful, the data in the data store should be a reliable data this reliable data is also called as consistent data.
Isolation: Isolation means, if two transaction are going on same data then one transaction will not disturb another transaction.
Durability: Durability means, after a transaction is completed the data in the data store will be permanent until another transaction is going to be performed on that data.