SQL database interview question for fresher




1.What is SQL?

SQL stands for structured query language and we can access and manipulate databases.

2.How to create a table in SQL?


Create table tablname (

Name varchar(10),

ID int )

Varchar and int  is datatype 

3.How to delete a table in SQL?

Delete from tablename (all data delete from the table)

Delete from tablname where columnName='' (which row or column you want to delete)

4.How to change a table name in SQL?

ALTER TABLE exampletable RENAME TO new_table_name;

5.How to delete a row in SQL?

Delete from tablname where columnName='' (which row or column you want to delete)

6.How to create a database in SQL?

"Create database databasename"   and press F5 after you see your database is created 

7.What is Normalization in SQL?

Ans:- The practise of normalisation improves data integrity in the table by removing redundant data and duplication. Additionally, normalisation aids in database data organisation. Setting the data into tabular form and removing duplicate data from relational tables involve several steps.

8.What is join in SQL?

Ans:- Based on a shared column between two or more tables, a JOIN clause is used to merge rows from those tables.

9.What is an SQL server?

Ans:- Microsoft created the relational database management system (RDBMS) known as SQL Server. It was created largely to compete with MySQL and Oracle databases. The standard SQL (Structured Query Language) language is supported by SQL Server. But T-SQL, the SQL language implementation that comes with SQL Server, is its own (Transact-SQL).

10.How to insert Date in SQL?

Ans:- INSERT INTO ‘STUDENT’ (‘S_id’, ‘DoB’, ‘Gender’,’Contact_No’, City) VALUES (‘S_02’, ‘1985-12-09’, ‘Male’, ‘098987899’, Delhi);

11. How can I see all tables in SQL?

Select * from information_schema.tables

12. What is ETL in SQL?

The SQL Server ETL (Extraction, Transformation, and Loading) process is particularly useful when there is no consistency in the data coming from the source system

13. What is the primary key?

Ans":- A primary key is a type of key column of table which uniquely identifies each tuple (row) or a record in a table. Only one primary key have in the table .  The primary key does't accept the any duplicate and NULL values

14. What is a foreign key?

Ans:- A field (or group of fields) in one table that refers to the PRIMARY KEY in another table is known as a FOREIGN KEY. The table with the main key is referred to as the parent table, while the table with the foreign key is referred to as the child table.

15. What is a union key?

Ans:- To merge the result-set of two or more SELECT statements, use the UNION operator. Within UNION, all SELECT statements must have an identical number of columns. Additionally, the columns' data types must be comparable. Every SELECT statement's columns must be in the same order.

16. What is join?

Ans:- In order to merge information or rows from two or more tables based on a shared field, use the SQL Join statement. The following list includes many join types:

 LEFT JOIN,

RIGHT JOIN

FULL JOIN

INNER JOIN

17. What is a self join?

Ans:- As its name suggests, the SELF JOIN in SQL is used to join a table to itself. This indicates that every row in a table is connected to every other row in the table as well as to itself. However, if a single query makes several references to the same table, an error will occur. SQL SELF JOIN aliases are employed to prevent this.

18. What is the Database?

Ans:- A SQL database, often known as a relational database, is made up of a number of highly structured tables where each row represents a certain type of data item and each column designates a particular field of data. Structured query language (SQL) is used to create, save, update, and retrieve data in relational databases.

19. What is RDBMS?

Ans:- Relational Database Management System is referred to as RDBMS. All contemporary database systems, including MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access, are built on the RDBMS platform.

20. What is Denormalization?

Ans:- Denormalization is the technique of introducing precomputed redundant data to a relational database that has otherwise been normalised in order to enhance read performance. Redundancy is eliminated during database normalisation so that each piece of data only exists once.

21.What is the table?

Ans:- All of the data in a database is stored in tables, which are database objects. Data is logically arranged in tables using a row-and-column layout akin to a spreadsheet. Each column denotes a record field, and each row denotes a distinct record.

22. What is the view?

Ans:- In SQL, views are a subset of virtual tables. The rows and columns of a view are identical to those in a database's actual table. By choosing fields from one or more database tables, we can build a view. A view may include all table rows or only certain rows according to a set of criteria.

23. What is Index?

Ans:- A SQL index is a quick lookup table used to locate records that users commonly need to search. An index is designed for quick lookups and is compact and quick. It is highly helpful for tying relational tables together and querying massive tables.

24. How to alter the existing column name in the table?

Ans:- The code below allows you to rename a column. By using the command ALTER TABLE table name to pick the table, you can then use the RENAME COLUMN old name TO new name command to specify which column to rename and what to call it.

ALTER TABLE table_name

RENAME COLUMN old_name TO new_name;

25. How to insert one table data to another table data?

26. What is Trigger ?

27. What is Dateadd SQL?

Ans:- A time/date interval is added to a date via the DATEADD() function, which then returns the original date.

28. What is With(NLOCK) ?

Ans:- By enabling the user to retrieve the data without being impacted by locks on the requested data because another process is modifying it, the WITH (NOLOCK) table hint can be used to override the default transaction isolation level of the table or the tables within the view in a particular query.