0% found this document useful (0 votes)
26 views2 pages

General Questions

The document discusses 3 common questions about SQL: 1. The main types of SQL statements including data retrieval, data manipulation, data definition, transaction control, and data control statements. 2. Common datatypes supported across Oracle, MySQL, and SQL Server including character, numeric, and datetime datatypes. 3. What a subquery is, the two main types (non-correlated and correlated), and examples of each type.

Uploaded by

Gajanand Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

General Questions

The document discusses 3 common questions about SQL: 1. The main types of SQL statements including data retrieval, data manipulation, data definition, transaction control, and data control statements. 2. Common datatypes supported across Oracle, MySQL, and SQL Server including character, numeric, and datetime datatypes. 3. What a subquery is, the two main types (non-correlated and correlated), and examples of each type.

Uploaded by

Gajanand Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

General Questions

Q1. Types of SQL Statements?


a) Data Retrieval/ Query Language – SELECT
b) DML – INSERT, UPDATE, DELETE, MERGE
c) DDL – CREATE, ALTER, DROP, RENAME, TRUNCATE
d) TCS – COMMIT, ROLLBACK, SAVEPOINT
e) DCL – GRANT, REVOKE

Q2. Datatypes in Databases?


ORACLE MYSQL SQL SERVER
Char(n) Char(n) Char(n)
Varchar2(n) Varchar(n) Varchar(n)
CHARACTER
Clob/ Blob Blob/ Text Varchar(max)
Long Longtext Text
Number(3) Tinyint Tinyint
Number(5) Smallint Smallint
Number(10) Mediumint Integer
Number(19) Int Bigint
NUMERIC
Number(p,s) Bigint Decimal(p,s)
Number(p,s) Float(m,d) Numeric(p,s)
Double(m,d)
Decimal(m,d)
Date Date Date
Datetime Datetime
DATETIME Timestamp
Time
Year(m)

Q3. What is a subquery and its types?


A Subquery is a query within another SQL Query. (Inner Query or a Nested Query). The result
returned by the inner query will be used as an input to outer query.

Types of Subqueries are:

1. Non- Correlated Subquery (Simple Subquery)


This is further divided into:
- Single Row Subquery
SELECT * FROM emp WHERE sal=(SELECT MAX(sal) FROM emp);
- Multi Row Subquery
SELECT * FROM emp WHERE deptno in (SELECT deptno FROM emp WHERE loc='NEW
YORK');
- Multi Column Subquery
SELECT * FROM emp WHERE (deptno,sal) IN (SELECT MAX(sal) FROM emp GROUP BY
deptno);

2. Correlated Subquery
SELECT * FROM emp a WHERE 1=(SELECT COUNT(*) FROM emp b WHERE b.sal>=a.sal);

A correlated subquery is a subquery that refers to a column of a table that is not in its
FROM clause. The column can be in the Projection clause or in the WHERE clause.

You might also like