Monday, 9 April 2012

SQL interview question and answers

What is SQL?
SQL, SEQUEL (Structured English Query Language), is a language for RDBMS (Relational Database Management Systems). SQL was developed by IBM Corporation.


How many categories of data types?
Oracle supports the following categories of data types:
Oracle Built-in Datatypes.
ANSI, DB2, and SQL/DS Datatypes.
User-Defined Types.
Oracle-Supplied Types.


What are the Oracle Built-in Data Types?
There are 20 Oracle built-in data types, divided into 6 groups:
Character Datatypes - CHAR, NCHAR, NVARCHAR2, VARCHAR2
Number Datatypes - NUMBER, BINARY_FLOAT, BINARY_DOUBLE
Long and Row Datatypes - LONG, LONG RAW, RAW
Datetime Datatypes - DATE, TIMESTAMP, INTERVAL YEAR TO MONTH,
INTERVAL DAY TO SECOND
Large Object Datatypes - BLOB, CLOB, NCLOB, BFILE
Row ID Datatypes - ROWID, UROWID


What Are the Differences between CHAR and NCHAR?
Both CHAR and NCHAR are fixed length character data types. But they have the
following differences:
CHAR's size is specified in bytes by default.
NCHAR's size is specified in characters by default. A character could be 1
byte to 4 bytes long depending on the character set used.
NCHAR stores characters in Unicode.


What Are the Differences between CHAR and VARCHAR2?
The main differences between CHAR and VARCHAR2 are:
CHAR stores values in fixed lengths. Values are padded with space characters
to match the specified length.
VARCHAR2 stores values in variable lengths. Values are not padded with any
characters.


What Are the Differences between NUMBER and BINARY_FLOAT?
The main differences between NUMBER and BINARY_FLOAT are:
NUMBER stores values as fixed-point numbers using 1 to 22 bytes.
BINARY_FLOAT stores values as single precision floating-point numbers.


What Are the Differences between DATE and TIMESTAMP?
The main differences between DATE and TIMESTAMP are:
DATE stores values as century, year, month, date, hour, minute, and second.
TIMESTAMP stores values as year, month, day, hour, minute, second, and
fractional seconds.


What Are the Differences between INTERVAL YEAR TO MONTH and
INTERVAL DAY TO SECOND?
The main differences between INTERVAL YEAR TO MONTH and INTERVAL DAY TO
SECOND are:
INTERVAL YEAR TO MONTH stores values as time intervals at the month
level.
INTERVAL DAY TO SECOND stores values as time intervals at the fractional
seconds level.


What Are the Differences between BLOB and CLOB?
The main differences between BLOB and CLOB are:
BLOB stores values as LOB (Large OBject) in bitstreams.
CLOB stores values as LOB (Large OBject) in character steams


What Are the ANSI Data Types Supported in Oracle?
The following ANSI data types are supported in Oracle:
CHARACTER(n) / CHAR(n)
CHARACTER VARYING(n) / CHAR VARYING(n)
NATIONAL CHARACTER(n) / NATIONAL CHAR(n) / NCHAR(n)
NATIONAL CHARACTER VARYING(n) / NATIONAL CHAR VARYING(n) / NCHAR
VARYING(n)
NUMERIC(p,s)
DECIMAL(p,s)
INTEGER / INT
SMALLINT
FLOAT
DOUBLE PRECISION
REAL

No comments:

Post a Comment

Do you want to comment