You are on page 1of 10

Q#1. What does SQL stand for?

Ans. SQL stands for Structured Query Language.
Q#2. How to select all records from the table?
Ans. To select all the records from the table we need to use following syntax:
Select * from table_name;

Q#3. Define join and name different type of joins?
Ans. Join keyword is used to fetch data from related two or more tables. It returns rows
where there is at least one match in both the tables included in join. Read more here.
Type of joins are-
1. Right Join
2. Outer Join
3. Full Join
4. Cross Join
5. Self Join.
Q#4. What is the syntax to add record to a table?
Ans. To add record in a table INSERT syntax is used.
Ex: INSERT into table_name VALUES (value1, value2..);

Q#5. How do you add a column to a table?
Ans. To add another column in the table following command has been used.
ALTER TABLE table_name ADD (column_name);

Q#6. Define SQL Delete statement.
Ans. Delete is used to delete a row or rows from a table based on the specified
Basic syntax is as follows:
DELETE FROM table_name

WHERE <Condition>

Q#7. Define COMMIT ?
Ans. COMMIT saves all changes made by DML statements.
Q#8. What is a primary key?
Ans. A Primary key is column whose values uniquely identify every row in a table.
Primary key values can never be reused.
Q#9. What are foreign keys?
Ans. When a one table’s primary key field is added to related tables in order to create
the common field which relates the two tables, it called a foreign key in other tables.
Foreign Key constraints enforce referential integrity.
Q#10. What is CHECK Constraint?
Ans. A CHECK constraint is used to limit the values or type of data that can be stored in
a column. They are used to enforce domain integrity.
Q#11. Is it possible for a table to have more than one foreign key?
Ans. Yes, a table can have many foreign keys and only one primary key.

CREATE . ORDER BY. Trigger allows us to execute a batch of SQL code when a table event occurs (Insert. Q#20. SQL comments can be put by two consecutive hyphens (–). What is Normalization? Ans. HAVING. What is a stored procedure? Ans. Q#16. The process of table design to minimize the data redundancy is called normalization. . we need to use the DISTINCT keyword. Marks FROM Student s1 where 3 <= (SELECT COUNT(*) FROM Students s2 WHERE s1. SELECT DISTINCT name FROM table_name. Which TCP/IP port does SQL Server run? Ans. By default SQL Server runs on port 1433.marks) Q#24. An identity column in the SQL automatically generates numeric values. Give the order of SQL SELECT ? Ans. Order of SQL SELECT clauses is: SELECT. DML stands for Data Manipulation Language. Example: SELECT * FROM table_name SAMPLE(10). What is Trigger? Ans.Q#12. UPDATE and DELETE are DML statements. Q#14. Q#13. What are the possible values for BOOLEAN data field. Q#18. Q#22. Name and Marks. Explain DML and DDL? Ans.marks = s2. INSERT. RENAME are DDL statements. What is SQL comments? Ans. Only the SELECT and FROM clause are mandatory. Ans. Q#15. Ans. Using SAMPLE clause we can select random rows. A stored procedure is a set of SQL queries which can take input and send back output. SELECT column_name AS new_name FROM table_name. How to get name and marks of top three students. We can defined a start and increment value of identity column. SELECT Name. To get the each name only once. Q#23. Q#21.ALTER. DDL stands for Data Definition Language. update or delete command executed against a specific table) Q#17. DROP. We need to divide a database into two or more table and define relationships between them. What is identity in SQL? Ans. Suppose a Student column has two columns. For a BOOLEAN data field two values are possible: -1(true) and 0(false). Q#19. GROUP BY. Yes using the following syntax we can do this. Can we rename a column in the output of SQL query? Ans. FROM. WHERE. How to select random rows from a table? Ans. Write a SQL SELECT query that only returns each name only once from a table? Ans.

Durability. A Subquery is sub set of select statements whose return values are used in filtering conditions of the main query. What do you mean by ROWID ? Ans. INTERSECT – returns all distinct rows selected by both queries. It’s a 18 character long pseudo column attached with each row of a table. Q#29. Q#28. including all duplicates. What are the properties of a transaction? Ans.Q#25. What is an Index ? Ans. What is a composite primary key? Ans. Q#26. UNION ALL. Q#31. A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. Primary key cannot contain Null values whereas Unique key can contain Null values. INTERSECT ? Ans. . The operation cannot be rolled back DROP command removes a table from the database completely. Q#32. What is the Subquery ? Ans. An Index is an special structure associated with a table speed up the performance of queries. MINUS – returns all distinct rows selected by the first query but not by the second. Isolation 4. Index can be created on one or more columns of a table. Atomicity 2. UNION – returns all distinct rows selected by either query UNION ALL – returns all rows selected by either query. A transaction is a sequence of code that runs against a database. Difference between TRUNCATE. They are: 1. TRUNCATE removes ALL rows from a table by de-allocating the memory pages. MINUS. What is a transaction? Ans. DELETE removes some or all rows from a table based on the condition. Primary key created on more than one column is called composite primary key. What is difference between UNIQUE and PRIMARY KEY constraints? Ans. DELETE and DROP commands? Ans. It takes database from one consistent state to another. Q#27. ------------ Q#30. It can be rolled back. Consistency 3. Define UNION. Q#33. Generally these properties are referred as ACID properties.

A temp table is a temporary storage structure to store the data temporarily. Do View contain Data? Ans. Q#44. Can a View based on another View? Ans. Both specify a search condition but Having clause is used only with the SELECT statement and typically used with GROUP BY clause. Q#35. By using DISTINCT keyword duplicating records in a query can be avoided. Advantages of Views: 1. List the various privileges that a user can grant to another user? Ans. Q#37. If defined in inside a compound statement a local temporary table exists only for . Views can be used to make simple queries to retrieve the results of complicated queries. It evaluates a list of conditions and returns one of multiple possible result expressions. Query optimization is a process in which database system compares different query strategies and select the query with the least cost. Q#38. Q#43. What is Case Function? Ans. Q#48. A view is a virtual table which contains data from one or more tables. A schema is collection of database objects of a User. Q#42. how case sensitivity and Kana character can be treated etc. Case facilitates if-then-else type of logic in SQL. Views restrict access to the data because the view can display selective columns from the table. Q#49. Views are virtual structure. What is Table ? Ans. Views restrict data access of table by selecting only required values and make complex queries easy. Q#46. Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column. 2. Q#39. Set of rules that defines how data is stored. Q#41. What is schema? Ans. What is Referential Integrity? Ans. A table is the basic unit of data storage in the database management system. No. SELECT. Q#36. What is a View? Ans. How we can avoid duplicating records in a query? Ans. For example. Explain the difference between Rename and Alias? Ans. Q#40. A View is based on another View.Q#34. Q#47. CONNECT. views can be used to query information from multiple tables without the user knowing. Set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table. Yes. What do you mean by query optimization? Ans. What is difference between Local and Global temporary table? Ans. Q#45. If GROUP BY clause is not used then Having behaves like WHERE clause only. What is difference between Having clause and Where clause? Ans. Table data is stored in rows and columns. What are the advantages of Views? Ans. What is Collation? Ans. RESOURCES. Define a temp table? Ans.

JACKSON D. Write a SQL SELECT sample of the concatenation operator. CLARK C. both of these values would have been returned. SELECT LastName ||'. You issue the following query:SELECT FirstName FROM StaffListWHERE FirstName LIKE'_A%'Which names would be returned by this query? Choose all that apply. The underscore (_) stands for any one character of any case. The Distinct keyword automatically sorts all data in ascending order.the duration of that statement but a global temporary table exists permanently in the db but its rows disappears when the connection is closed. SELECT DISTINCT City FROM Students. only strings with an uppercase "A" as their second letter are returned 23. ----------------------------------------------------------------------------------------------------------------- ------------------ 22. A. if you want the data sorted in descending order. Allen B. Q. Q. you have to use an ORDER BY clause 24. If the LIKE string had been "%A%". Because this string starts with an underscore rather than a percent sign. David A. A. it won't return Allen or Clark because they represent zero and two characters before the "A". However. Write a SQL SELECT query that only returns each city only once from Students table? Do you need to order this list with an ORDER BY clause? A. Q#50. City FROM Students.' || FirstName. What is CTE? Ans. and the percent sign (%) stands for any number of characters of any case including none. David was not returned because all non-wild card characters are case sensitive. . C is correct � Two wildcards are used with the LIKE operator. Q. Therefore. A CTE or common table expression is an expression which contains temporary result set which is defined in a SQL statement.

The MIN function works with any character. YYYY') . ROWNUM FROM Instructors. City AS "Home City" "FROM StudentsORDER BY "Student Name"  26. you use the "fm" prefix before the date element that contains the spaces. SELECT InstructorID. AVG B. LastName. Q. Q. or date datatype. SELECT FirstName. YYYY') ? A. Q. DD. but Oracle 8i has replaced them with a single TRIM function 30. MIN C. Which of the following functions can be used only with numeric values? (Choose all that apply. 29. C � The TRIM function is used to remove padded spaces. Write SQL SELECT example how you limiting the rows returned with a WHERE clause.'fmMonth DD. TRIM A. Which function do you use to remove all padded characters to the right of a character value in a column with a char datatype? A. Q. RTRIM B.25. RPAD C. Write SQL SELECT query that returns the first and last name of each instructor.' || FirstName AS "Student Name". LENGTH D. SELECT LastName ||'. numeric. and gives each of them a number. Q. 28. 27. A.'Month. ROUND A. TO_CHAR(SYSDATE. Q. SUM E. The LENGTH function is a character function that returns the number of letters in a character value. Salary FROM Instructors WHERE Salary > 5400 AND Salary < 6600. The ROUND function works with both numeric and date values. LTRIM and RTRIM functions were included in earlier versions of Oracle. A and D � Only A and D are correct. A. How to rename column in the SQL SELECT query? A. Which statement do you use to eliminate padded spaces between the month and day values in a function TO_CHAR(SYSDATE. the Salary.) A. Salary. To remove padded spaces.

Which operator do you use to return all of the rows from one query except rows are returned in a second query? A. Q. 32. If you specify an alias in l owercase letters without double quotes. Only the SELECT and FROM clause are mandatory. ORDER BY. Yes. The proper order for SQL SELECT clauses is: SELECT. GRANT D. Q. You must enclose the column alias in double quotes when the alias contains a space or lowercase letters. Which of the following statements are Data Manipulation Language commands? A. What Oracle lock modes do you know? A. The AS keyword is optional when specifying a column alias. 34. WHERE. Q. Question. 33. TRUNCATE and CREATE are Data Definition Language (DDL) commands 36. Query optimization is the part of the query process in which the database system compares different query strategies and chooses the one with the least expected cost .31. The INTERSECT operator returns only those rows that exist in both queries. Oracle has two lock modes: shared or exclusive. A and B � The INSERT and UPDATE statements are Data Manipulation Language (DML) commands. Q. It is the outermost query that returns a result set. it always executes the innermost query first. You use the MINUS operator to return all rows from one query except where duplicate rows are found in a second query. Oracle uses locking mechanisms to protect data from being destroyed by concurrent transactions. INSERT B. the alias will appear in uppercase. UPDATE C. GRANT is a Data Control Language (DCL) command. Exclusive locks are set on resources that ensure one transaction has exclusive access to the database resource 38. How Oracle executes a statement with nested subqueries? A. What is query optimization? A. Question. CREATE A. 35 Q. Question. GROUP BY. The UNION operator returns all rows from both queries minus duplicates. How you will create a column alias? (Oracle 8i) A. Shared locks are set on database resources so that many transactions can access the resource. The UNION ALL operator returns all rows from both queries including duplicates. Is the WHERE clause must appear always before the GROUP BY clause in SQL SELECT ? A. What is Oracle locking? A. When Oracle executes a statement with nested subqueries. 37. FROM. HAVING. TRUNCATE E. This query passes its results to the next query and so on until it reaches the outermost query.

A database management system is composed of five elements: computer hardware. Describe some Group Functions that you know A.ACTIVE_IND = 'Y' AND a.FILE_NUM. Answer: j and a aliases for table names. Describe some Conversion Functions that you know A. Question. this is outer joint select statament from two tables.OFFICE_ID = '101' AND a.FILE_NUM from DB_name. Question. The database management system software includes components for storage management.job j. 44. A transaction is a collection of applications code and database manipulation code bound into an indivisible unit of execution. SELECT COUNT(*) FROM TESTING. Q. software. 40. TO_CHAR converts a number / date to a string. Question. What are the main attributes of database management system? A. Explain SQL SELECT example: select j.QA . and database control interface.FILE_NUM = j.OFFICE_ID = '101' AND j. A.JOB_TYPE ='C' AND j.39. 41. Question. database definition interface. What are the main components of Database management systems software. and operations procedures. What is transaction? A. DB_name. concurrency control.address a where j. Q. Question. data. What databases do you know? Informix DB2 SQL Oracle 43. transaction processing. people (users). database manipulation interface. TO_DATE converts a string (representing a date) to a date. it accepts one parameter which is a column value or a string literal 45.COMPANY_NAME = 'TEST6' AND j. it consists from: BEGIN-TRANSACTION Name Code END TRANSACTION Name 42.ADDRESS_STATUS_ID = 'H' AND a. 1) The COUNT function tells you how many rows were in the result set. TO_NUMBER converts a character string containing digits to a numeric data type.FILE_NUM order by j.

SELECT clause 6.QA 46.num. GROUP BY clause 4. Q. SQL comments are introduced by two consecutive hyphens (--) and ended by the end of the line. Question: Describe SQL comments. DDL is Data Definition Language statements. TB2. SELECT SUM(SALARY) FROM TESTING.bu_id. FROM clause 2.program. Question: In the domain table we have status as a numeric value from 01 to 04 and we have text definition of these values in the design document. 50. TO_DATE is a synonym for TIMESTAMP_FORMAT. HAVING clause 5. What does DDL stand for? A. 52.status when '01' then 'Auto renew' when '02' then 'Expired' when '03' then 'Sold' when '04' then ‘Terminated’ else TB_name. TB1. (CREATE) 48.status end . Write SQL query to see the result as a text definitions that is corresponded to these values. TB1. (COMMIT) 49. SELECT MAX(SALARY) FROM TESTING. (SELECT) 47. Describe TO_DATE function. ORDER BY clause 7. DML is Data Manipulation Language statements.QA 3) The MAX and MIN functions tell you the maximum and minimum value of a numeric column. FETCH FIRST clause 51. Question. WHERE clause 3.QA 4) The SUM function tells you the sum value of a numeric column. (DB2) A. SELECT MIN(SALARY) FROM TESTING. In what sequence SQL statement are processed? A. select TB1. 2) The AVG function tells you the average value of a numeric column. What does DCL stand for? A. Q. The clauses of the subselect are processed in the following sequence (DB2): 1. Question. A. case TB1. A. Question. What does DML stand for? A. The TO_DATE function returns a timestamp from a character string that has been interpreted using a character template.member_id. DCL is Data Control Language statements.

. apartment CHAR(8). )." 54. if any.member_role = '100' order by TB1. write a SQL statement that returns no apartment addresses only. in which case the first yields a one-column.member_id fetch first 30 rows only 53. They're the same unless table T is empty. city CHAR(30) NOT NULL. DB_name. one-row table "containing a null. from DB_name.program in ('com'. Question: What's the logical difference. between the following SQL expressions? SELECT COUNT ( * ) FROM T SELECT SUM ( 1 ) FROM T A. one-row table containing a zero and the second yields a one- column. Question: we have a table Address ( street CHAR(20) NOT NULL.TB_name1 TB1. 'org') and TB1. Answer: SELECT * FROM Address WHERE apartment IS NULL.TB_name2 TB2 where TB1.