You are right place, If you are looking for SQL Interview Questions and answers, get more confidence to crack interview by reading this questions and answers we will update more and more latest questions for you…
1. What is SQL?SQL Full Form for Structured Query Language. It is an American National Standard Institute (ANSI) Recognized. It is a standard language for accessing and Manage Databases. Using SQL, some of the action we could do are to create databases, tables, stored procedures (SP’s), execute queries, retrieve, insert, and update, delete data against a database
2. What is a Database?A Database is Determine as a structured form of data which is stored in a computer or data in an organized manner and can be accessed in various ways. It is also the collection of schemas, tables, queries, views, etc. The database helps us in easily storing, accessing and manipulation of data held in a computer. The Database Management System allows a user to Connect with the database
[ Related Article - What is Database Management? ]
3. What is RDBMS?RDBMS stands for Relational Database Management System. RDBMS is a database management system (DBMS) that is based on the relational model. Data from a relational database can be accessed using Structured Query Language (SQL)
4. What are the different types of SQL commands?SQL commands are isolated into the following types: DDL – Data Definition LanguageDML – Data Manipulation LanguageDQL – Data Query LanguageDCL – Data Control LanguageTCL – Transaction Control Language5. What do you mean by foreign key?
A Foreign key is a field which can uniquely identify each row in Other Tables. And this constraint is utilized to specify a field as foreign key. That is, this field points to the primary key of another table. This usually creates a kind of link between the two tables.
OREDERS
O_ID | ORDER NUMBER | C_ID |
1 | 2253 | 3 |
2 | 3325 | 3 |
3 | 4521 | 2 |
4 | 8532 | 1 |
C_ID | NAME | ADDRESS |
1 | RAMESH | DELHI |
2 | SURESH | NOIDA |
3 | DHARMESH | GURGAON |
Customers
As we can see surely that the field C_ID in Orders table is the primary key in the Customers table, i.e. it uniquely identifies each row in the Customers table. Therefore, it is a Foreign Key in the Orders table.
Syntax:
CREATE TABLE
Orders
(
O_ID int NOT NULL,
ORDER_NO int NOT NULL,
C_ID int,
PRIMARY KEY (O_ID),
FOREIGN KEY (C_ID) REFERENCES Customers (C_ID)
)
6. Does SQL support programming language features?It is true that SQL is a language but it does not encourage programming as it is not a programming language, it is a command language. We don't have conditional statements in SQL like for loops or if. Else, we only have commands which we can use to query, update, delete, and etc. data in the database. SQL allows us to control data in a database.
7. What is a query?A database query is an appeal for data or information from a database table or combination of tables. A database query can be either or a select query or an action query.
[ Related Article - What is SQL Query? ]
8. What is data Integrity?Data integrity defines the accuracy and consistency of the data stored in a database. It also describes integrity constraints to enforce business rules on the data when it is entered into an application or a database.
9. What is Auto Increment in SQL?Auto increment keyword allows the user to create a unique number to get generated when a new record is inserted into a table. Auto increment keyword can be utilized whenever Primary Key is used.
10. What is DBMS?Database Management System is a Group of programs that enables a user to store, retrieve, update and delete information from a database.
11. What are the different DCL commands in SQL?DCL commands are utilized to create roles, grant permission and control access to the database objects.
GRANT: To provide user accessDENY: To deny permissions to usersREVOKE: To remove user access
12. What are the different TCL commands in SQL?
TCL commands are used to balance the changes made by DML statements.
COMMIT: write and store the changes to the databaseROLLBACK: To restore the database since for the last commit
13. What is a SUB query?
A Sub query is a SQL query within One More query. It is a subset of a Select statement whose return values are utilized in filtering the conditions of the main query.
14. What is the difference between an inner and outer join?An inner join returns rows when there is at least some related data between two (or more) tables that are being compared.
An outer join returns rows from both tables that include the records that are unmatched from one or both the tables.
15. What is stored procedure?
A Stored agenda is a collection of SQL statements that have been created and stored in the database to perform a particular task. The stored agenda accepts input parameters and processes them and returns a single value such as a number or text value or a result set (set of rows).
16. What is an Index?
An index is used to speed up the Achievement of queries. It makes faster retrieval of data from the table. The index can be generated on one column or a group of columns.
17. What is embedded and dynamic SQL?SQL statements in an application that don't change at runtime and, therefore, can be hard-coded into the application.
Dynamic SQL
SQL statements that are constructed at runtime; for example, the application may Grant users to enter their own queries.
Dynamic SQL is a programming technique that approves you to build SQL statements dynamically at runtime. You can create more general purpose, adjustable applications by using dynamic SQL because the full text of a SQL statement may be unknown at compilation.
18. What are Operators available in SQL?SQL Operator is a Reserved word used mainly in an SQL statement’s WHERE clause to Behave operations, such as arithmetic operations and comparisons. These are used to specify conditions in an SQL statement.
There are 3 types of Operators.
Arithmetic Operators Comparison Operators Logical Operators 19. What is the order of SQL SELECT?Order of SQL SELECT statement is as follows
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY20. What is Collation?
Collation is Describe as a set of rules that determine how character data can be arranged as well as compared. Character data is arranged using rules that define the correct character sequence along with options for specifying case-sensitivity, character width, accent marks, and kana character types
21. What are string functions in SQL?
SQL string functions are used mainly for string manipulation. Some of the generally used SQL string functions are
LEN() – It returns the length of the value in a text fieldLOWER() – It converts character data to lower caseUPPER() – It converts character data to upper caseSUBSTRING() – It extracts characters from a text fieldLTRIM() – It is to remove all whitespace from the beginning of the stringRTRIM() – It is to remove all whitespace at the end of the stringCONCAT() – Concatenate function combines multiple character strings togetherREPLACE () – To update the content of a string.22. What is SQL Sandbox in SQL Server?
SQL Sandbox is the secure place in SQL Server Environment where un trusted scripts are executed. There are three types of SQL sandbox, such as
Safe Access Sandbox: The user can perform SQL operations such as creating stored procedures, triggers, etc. but can’t have access to the memory and can't create files.
External Access Sandbox: User can have access to files without having a right to manage the memory allocation.
Unsafe Access Sandbox: It contains untrusted codes where a user can have access to memory.
23. What is Denormalization?De Normalization is a technique used to access the data from higher to lower normal forms of the database. It is also the process of introducing redundancy into a table by incorporating data from the related tables.
24. How to add a column ‘Salary’ to a table Employee Details?ALTER TABLE Employee Details ADD (Salary);
25. Define SQL Delete statement?The SQL Delete statement is used to delete records from a table.
DELETE FROM table_name WHERE some_column=some_value;
26. How to Get List of All Tables from A Database?To view the tables available on a particular Database
USE TestDBGOSELECT * FROM sys.TablesGO?
Triggers may develop data modification logic by using INSERT, UPDATE,and DELETE statement. These triggers that contain data Changing logic and find other triggers for data modification are called Nested Triggers.
27. How to rename a column in the output of SQL query?By using SQL AS keyword
SELECT column_name AS new_name FROM table_name;
28. What is CLAUSE in SQL?SQL CLAUSE more helps to limit the result set by providing a condition to an SQL Query. A CLAUSE helps to filter the rows from the vital set of records. SQL CLAUSES are WHERE & HAVING.