techpreparation-homepage

Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions
Oracle Interview Questions
MySql Interview Questions
MsSql Interview Questions
JDBC Interview Questions
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

 

 

  

Sql Interview Questions and Answers



Operators used in SELECT statements.
= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN an inclusive range
LIKE Search for a pattern


SELECT statements:


SELECT column_name(s) FROM table_name
SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value
Note that single quotes around text values and numeric values should not be enclosed in quotes. Double quotes may be acceptable in some databases.


The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records.


SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name operator value


The INSERT INTO Statements:



INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)


The Update Statement:


UPDATE table_name SET column_name = new_value WHERE column_name = some_value


The Delete Statements:


DELETE FROM table_name WHERE column_name = some_value
Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name


Sort the Rows:


SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC


The IN operator may be used if you know the exact value you want to return for at least one of the columns.


SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..)


BETWEEN ... AND

SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers, text, or dates.


What is the use of CASCADE CONSTRAINTS?

When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.


Why does the following command give a compilation error?

DROP TABLE &TABLE_NAME; Variable names should start with an alphabet. Here the table name starts with an '&' symbol.

Which system tables contain information on privileges granted and privileges obtained?
USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD

Which system table contains information on constraints on all the tables created?obtained?
USER_CONSTRAINTS.


What is the difference between TRUNCATE and DELETE commands?

True 

Page Numbers :   1         2         3         4        5        6        7        8        9        10       11

Have a Question ? post your questions here. It will be answered as soon as possible.

Check HTML Interview Questions for more HTML Interview Questions with Answers

Check Job Interview Questions for more Interview Questions with Answers