You are on page 1of 5

Question 1: Provide the create table syntax to Create a Table Employee whose details are as below.

Employee(EmployeeID, LastName, FirstName, Address, DateHired) Answer: Create table Employee(EmployeeID integer, LastName varchar(10), FirstName varchar(10), Address varchar(20), DateHired date,primary key(EmployeeID)); Question 2: Provide the INSERT query to be used in Employee Table to fill the Details. Answer: insert into Employee values(1,abc,'xyz,'gandhi nagar,hyd,2011-12-20); Question 3: When we give SELECT * FROM EMPLOYEE .How does it Respond? Answer: It returns all the records from the Employee table Question 4: Create a Table CLIENT whose details are as below. Client(ClientID, LastName, FirstName, Balance, EmployeeID) Answer: Create table Client(ClientID integer,LastName varchar(10),Balance float(4),EmployeeID integer,primary key(ClientID)); Question 5: Provide the INSERT query to be used in CLIENT Table to fill the Details. Answer: insert into Client values(100,fgh,230.6789,2); Question 6: When we give SELECT * FROM CLIENT .How does it Respond? Answer: It returns all the records from the Client table Question 7: Choose the correct answer. The SQL command to create a table is: a. Make Table b. Alter Table c. Define Table d. Create Table Answer: d Question 8:

Choose the correct answer. The DROP TABLE statement: a. deletes the table structure only b. deletes the table structure along with the table data c. works whether or not referential integrity constraints would be violated d. is not an SQL statement Answer:b Question 9: What are the different data types available in SQL server? Answer: 1.char(n): Fixed length character string, with user-specified length n. 2.varchar(n): Variable length character strings, with user-specified maximum length n. 3.integer: Integer (a finite subset of the integers that is machine-dependent) 4.smallint: Small integer (a machine-dependent subset of the integer domain type). 5.numeric(p,d): Fixed point number, with user-specified precision of p digits, with n digits to the right of decimal point. 6.real, double precision: Floating point and double-precision floating point numbers, with machine-dependent precision. 7.float(n): Floating point number, with user-specified precision of at least ndigits. 8.date: Dates, containing a (4 digit) year, month and date eg. date 2005-7-27 9.time: Time of day, in hours, minutes and seconds. eg. time 09:00:30 time 09:00:30.75 10.timestamp: date plus time of day eg: timestamp 2011-7-27 09:00:30.75 11.interval: period of time eg. interval 1 day Note:Subtracting a date/time/timestamp value from another gives an interval value Interval values can be added to date/time/timestamp values 12.image:image variables store up to 2 gigabytes of data and are commonly used to store any type of data file (not just images). 13.cursor:these variables store references to cursors used for database operations. A table may not contain a cursor variable.

14.sql_variant:these variables store up to 8,000 bytes of data from any SQL Server data type other than varchar(max), nvarchar(max), text, image, sql_variant, varbinary(max), xml, ntext and timestamp. 15.table:these variables store temporary tables used during database operations. SQL Server database tables may not contain variables of type table. 16.xml : xmlvariables store XML formatted data. They may store a maximum of 2 gigabytes. 17.unique: unique identifier variables store 16-bit globally unique identifiers. Question 10: Which is the subset of SQL commands used to manipulate Oracle Database structures, includingtables? Answer: DDL: Data Definition Language is the subset which is used to manipulate Oracle database structures. i.e. Create, Alter, Drop DML statements manipulate only data within the data structures already created by DDL statements. Question 11: What operator performs pattern matching? Answer: like is the operator used in pattern matching. Question 12: What operator tests column for the absence of data? Answer: is null operator eg.select loan_number from loan where amount is null Question 13: Which command executes the contents of a specified file? Answer: START <filename> or @<filename>. Question 14: What is the parameter substitution symbol used with INSERT INTO command? Answer: & is substitution symbol used with insert into command. Question 15: Which command displays the SQL command in the SQL buffer, and then executes it? Answer: Run

Question 16: What are the wildcards used for pattern matching? Answer: _ for single character substitution and % for multi-character substitution. Question 17: State whether true or false. EXISTS, SOME, ANY are operators in SQL. Answer:True Question 18: State whether true or false. !=, <>, ^= all denote the same operation. Answer: True Question 19: What are the privileges that can be granted on a table by a user to others? Answer: Insert, update, delete, select, references, index, execute, alter, all Question 20: What command is used to get back the privileges offered by the GRANT command? Answer: revoke is the command which revokes access privileges for database objects previously granted to other users. Question 21: Which system tables contain information on privileges granted and privileges obtained? Answer: user_tab_privs_made , user_tab_privs_recd Question 22: Which system table contains information on constraints on all the tables created? Answer: USER_CONSTRAINTS (show all constraints created by the user who has logged in) ALL_CONSTRAINTS (accessible for dba user only) Question 23:

What is the difference between TRUNCATE and DELETE commands? Answer: 1. TRUNCATE is a DDL command whereas DELETE is a DML command. 2.TRUNCATE is much faster than DELETE. Reason: When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed. when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Hence TRUNCATE is faster.Once you Truncate you cannot get back the data. 3.You cannot rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently. 4.In case of TRUNCATE ,Trigger doesnt get fired.But in DML commands like DELETE ,Trigger get fired. 5.You cannot use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause Question 24: What command is used to create a table by copying the structure of another table? Answer: select * into newtablename from existing_table_name where 1=2 Note: if we want to copy both structure and constraints then select * into newtablename from oldtablename check the answers and then submit.

You might also like