Vous êtes sur la page 1sur 6

TCS ASPIRE PRE ILP ENGAGEMENT PROGRAM DATABASE AND SQL ASSIGNMENT

T.J.Priyankaa ( CT20100221902)

Question 1: Provide the create table syntax to Create a Table Employee whose details are as below.Employee(EmployeeID, LastName, FirstName, Address, DateHired) Ans: 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. Ans: Insert into Employee values( 140,'priyanka','aashan','chennai','2011-10-27');

Question 3: When we give SELECT * FROM EMPLOYEE .How does it Respond? Ans: The following query of select * from employee returns all the data, present in employee table.

Question 4: Create a Table CLIENT whose details are as below. Client(ClientID, LastName, FirstName, Balance, EmployeeID) Ans: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. Ans:INSERT INTO Client(ClientID,LastName,FirstName,Address, EmployeeId) Values (value1,value2,value3,value4 );

also the dynamic way to insert values into the table using the '&' operation can be done Example: ('& value1','&value2' and so on ... )

Question 6: When we give SELECT * FROM CLIENT .How does it Respond? ANS: It returns all the records present in the client table . That is it shows all the field data of 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 Ans : D -create table <tablename>

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 ANS: b

Question 9: What are the different data types available in SQL server? Ans: 1) Numeric : Stores numeric values.

2) Monetary

: It stores numeric values with decimal places. It is used specially for currency values.

3) Date and Time : It stores date and time information. 4) Character : It supports character based values of varying lengths. 5) Binary : It stores data in strict binary (0 or 1) representation. 6) Special purpose: SQL Server contains Complex data types to handle the XML Documents,Globally unique identifiers etc.

Question 10: Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables? ANS: DDL( Data Deifinition Language). 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? ANS: LIKE Operator.

Question 12: What operator tests column for the absence of data? ANS: IS NULL Operator.

Question 13: Which command executes the contents of a specified file? ANS: START <filename> or @<filename>.

Question 14: What is the parameter substitution symbol used with INSERT INTO command? ANS: '&' commonly known as amperesand operator.

Question 15: Which command displays the SQL command in the SQL buffer, and then executes it? ANS: RUN.

Question 16: What are the wildcards used for pattern ANS: _ and % _ = single character substitution . % = multiple character substitution.

Question 17: State whether true or false. EXISTS, SOME, ANY are operators in SQL. ANS: TRUE.

Question 18: State whether true or false. !=, <>, ^= all denote the same operation. ANS: TRUE.

Question 19: What are the privileges that can be granted on a table by a user to others? Ans: 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? ANS: REVOKE.

Question 21: Which system tables contain information on privileges granted and privileges obtained? ANS : USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD .

Question 22: Which system table contains information on constraints on all the tables created? ANS: 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? ANS: 1.DELETE is a DML command and TRUNCATE is a DDL command. 2.TRUNCATE is much faster than DELETE. Because when you type DELETE, all the data get copied into the Rollback Tablespace first and then delete operation is 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 takes 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? ANS: select * into newtablename from existing_table_name where 1=2

Vous aimerez peut-être aussi