SQL Interview questions and answers for freshers
- Get link
- X
- Other Apps
Posted by Ganesan - +919042710472
1. What is SQL?
SQL-Structured Query Language
It is a microsoft database which can be used for manipulation of datas.
2. What are the subsets of SQL?
DDL – Data Definition Language –It allows you to perform various operations on the database such as CREATE, ALTER and DELETE objects.
DML – Data Manipulation Language – It allows you to access and manipulate data. It helps you to INSERT, UPDATE, DELETE and RETRIVE data from the database.
DCL – Data Control Language – It allows you to control access to the database .example Grant, Revoke access permissions.
TCL – Transaction Control Language – Used to manage transactions in the database. Example COMMIT, ROLLBACK and SAVEPOINT.
3. How to create a table and add data
Syntax : CREATE TABLE table_name(
Column1 datatype,
Column2 datatype...
);
Create table StudentDetails(
StudentId int PRIMARY KEY,
StudentName varchar(100),
Age varchar(100),
);
Insert into StudentDetails values(1,'Vishnu',23);
4. Difference between TRUNCATE, DROP and DELETE?
TRUNCATE: Used to delete all the rows from the table and table structure remains.
DROP: If drop a table, all the rows in the table are deleted and the table structure is also removed from the database.
DELETE: Used to delete rows from a table. Can be roll backed.
Truncate table table_name;
Drop table table_name
Delete from table_name where id=1;.
5. What are constraints SQL ?
• NOT NULL: enforces a column to NOT accept NULL values.
• CHECK: Verifies that all values in a field satisfy a condition.
• DEFAULT: Assigns a default value if no value has been specified for the field.
• UNIQUE: Ensures unique values to be inserted into the field.
• PRIMARY KEY: Uniquely identifies each record in a table.
• FORIGN KEY: Referential integrity for a record in another table.
6. Difference between primary key and Unique key ?
Primary key: Only one primary key for a table. Cannot accept null values.
Unique key: Can have many unique keys for a table. Accept null values.
7. What is the SELECT statement?
SELECT is a SQL command that is used for selecting data from a database.
For example,
SELECT STUD_ID FROM STUDENTDETAILS;
Note: in the above SQL statement, ‘STUD_ID’ is a column and ‘STUDENTDETAILS’ is a table.
8. What are the different types of joins in SQL?
• Right join
• Left join
• Full join
• Inner join
• Self join
Joins – combine rows from two or more tables, based on a related column between them.
9. What is CLAUSE in SQL?
SQL clause helps to limit the result set by providing a condition to the query. A clause helps to filter the rows from the entire set of records.
For example, WHERE, HAVING clause.
10. What is the difference between SQL, SQL Server, and MySQL ?
SQL – Structured Query Language used to manage the relational database like Oracle, MS SQL Server, MySQL, Sybase, etc.
SQL Server and MySQL are relational database management systems used to store, retrieve, modify and administer a database using SQL.
MS SQL Server is a commercial database Management System whereas MYSQL is an open source software.
- Get link
- X
- Other Apps
Comments
Post a Comment