Академический Документы
Профессиональный Документы
Культура Документы
Like operator.
Eg:
IS NULL operator
5. What is the parameter substitution symbol used with INSERT INTO command?
&
6. Which command displays the SQL command in the SQL buffer, and then executes it?
Synonym of RUN is R
Note:'/' will only execute the last sql statement stored in the buffer and will not
display it.
LIST LIS LI or L will list (Display) the sql statement stored in the buffer but will
not execute.
7. What are the wildcards used for pattern matching?
True
9. State true or false. !=, <>, ^= all denote the same operation.
True
10. What are the privileges that can be granted on a table by a user to others?
11. What command is used to get back the privileges offered by the GRANT command?
REVOKE
12. Which system tables contain information on privileges granted and privileges obtained?
USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD
13. Which system table contains information on constraints on all the tables created?
USER_CONSTRAINTS
14. TRUNCATE TABLE EMP;,DELETE FROM EMP;, Will the outputs of the above two commands?
Both will result in deleting all the rows in the table EMP.
The difference is that the TRUNCATE call cannot be rolled back and all memory space for that
table is released back to the server. TRUNCATE is much faster than DELETE and in both cases
only the table data is removed, not the table structure.
a)
b)
1. For truncate command trigger will not get fired but for Delete Command Trigger will get
fired.
3.Once the truncate command is issued Transactions can't be rolled back whereas transactions can
be rolled back for Delete command.
16.What command is used to create a table by copying the structure of another table?
Answer :
Explanation :
To copy only the structure, the WHERE clause of the SELECT command should contain a
FALSE statement as in the following.
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied
to the new table.
TROUBLETHETROUBLE
This displays the total salary of all employees. The null values in the commission column will be
replaced by 0 and added to salary.
19.Which date function is used to find the difference between two dates?
MONTHS_BETWEEN
Variable names should start with an alphabet. Here the table name starts with an '&' symbol.
21.What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
The privilege receiver can further grant the privileges he/she has obtained from the owner to any
other user.
22. What is the use of the DROP option in the ALTER TABLE command?
23. What is the value of comm and sal after executing the following query if the initial value of ‘sal’
is 10000?
Answer :
DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in
descending order.
Explanation :
The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on
ENAME in descending order.
When this clause is used with the DROP command, a parent table can be dropped even when a
child table exists.
26. Which function is used to find the largest integer less than or equal to a specific value?
FLOOR
1200
28.What is the difference between Single row sub-Query and Scalar sub-Query?
Single row subqueries returns only one row of results.A single row sub query uses a single row
operator; the common operator is the equality operator( ).
A Scalar subquery returns exactly one column value from one row.Scalar subqueris can be ysed in
most places where you would use a column nae or expression such as inside a sigle row function
as an argument in insert order by clause where clause case expressions but not in group by or
having clause.
29. I have a table with duplicate names in it. Write me a query which returns only duplicate rows with
number of times they are repeated?
a)
b)
Used to return a dataset with unique entries for certain database table column
30.How do I write a cron which will run a SQL query and mail the results to a group?
Use DBMS_JOB for scheduling a cron job and DBMS_MAIL to send the results through email.
32. Is there any query which is use to find the case sensitivity in each records in database through visual
basic?
For case sensitive string comparison in SQL one has to use substring() and ascii() functions in the
following way.
For example if (ascii(substring(str1 @pos 1)) ascii(substring(str2 @pos 1)) then @pos @pos + 1 ....
a)
Stored procedure and Trigger both will be in the database in precompiled formate which ready execute the
main difference between these two is
to execute the stored procedure programe need to type execute statement where as to execute trigger
programer no need type execute statement trigger will fire automatically when an event(like insert delete)
on the table
b)
Information related to Stored procedure you can see in USER_SOURCE USER_OBJECTS(current user)
tables.
To retrieve data with SQL one row at a time you need to use cursor processing.Not all relational
databases support this but many do.Here I show this in Oracle with PL/SQL which is Procedural
Language SQL.Cursor processing is done in several steps:1. Define the rows you want to retrieve.
This is called declaring the cursor.2. Open the cursor. This activates the cursor and loads the data.
Note that declaring the cursor doesn't load data opening the cursor does.3. Fetch the data into
variables.4. Close the cursor.
a)
b)
1NF: If any tables have a many to many relationship this must be broken out using a JOIN table.
For example Customers can have many Suppliers and Suppliers can supply to many Customers.
This is known as a many to many relationship. You would need to create a JOIN table that would
have a primary key made up of a foreign key reference to the Customers table and a foreign key
reference to the suppliers table. Therefore the SuppliersPerCustomer table would be {SupplierID
CustomerID}. Now the Suppliers table will have a 1 to many relationship with the
SuppliersPerCustomer table and the Customers table will also have a 1 to many relationship with
the SuppliersPerCustomer table.
2NF: The database must meet all the requirements of the 1NF.
In addition records should not depend on anything other than a table's primary key (a primary key
can be made up of more than one field only if absolutely necessary like in a JOIN table).
Example:
A customers address is needed by the Customers table but also by the Orders and Invoices tables.
Instead of storing the customer's address as a separate entry in each of these tables store it in one
place either in the Customers table or in a separate Addresses table.
3NF : The database must meet all the requirements of the 1NF and 2NF.
A relational table is in third normal form (3NF) if it is already in 2NF and every non-key column
is non transitively dependent upon its primary key.
The Customer table contains information such as address city postcode imagine it also contained a
column called shipping cost. The value of shipping cost changes in relation to which city the
products are being delivered to and therefore is not directly dependent on the customer even
though the cost might not change per customer but it is dependent on the city that the customer is
in. Therefore we would need to create another separate table to hold the information about cities
and shipping costs.
36. How to find out the database name from SQL*PLUS command prompt?
37. How can we backup the sql files & what is SAP?
Use Export and Import tools for backups and restore resp.
you can use exp and imp as well
38.Whats the back end processes when we type "Select * from Table"?
First it will look into the System Global Area (SGA) weather the query is been exectued earlier.
If not the query we typed is complied and the resulting parse tree and excution plan is been stored
in SGA. Then query gets executed and output is given to the application.
a)
whereas
Structured Query Language (SQL) pronounced sequel is a language that provides an interface to
relational database systems. It was developed by IBM in the 1970s for use in System R. SQL is a
de facto standard as well as an ISO and ANSI standard. SQL is used to perform various operations
on RDBMS
b)
If I write SELECT SomeField FROM SomeTable that's a SQL statement. Of course by itself
simply typed into a text editor it doesn't do anything. It must be executed by a database engine that
understands how to translate the SQL statement into the low-level commands required to retrieve
the data from the proprietary database format. SQL Server is one such database engine.
a)
Tablespace is an logical storage structure at the highest level that stores all the data in datafiles.
b)
Table-space is a physical concept.it has pages where the records of the database is stored with a
logical perception of tables.so tablespace contains tables.
c)
A logical portion of a database used in allocating storage for table data and table indexes.
A tablespace is a logical structure that contains segments. Rollback data and index are the three
types of segments created inside a tablespace. Each segment is made up of extents and the extents
are comprised of data blocks.
The system tablespace contains the data dictionary for the Oracle database.
41.What is difference between Co-related sub query and nested sub query?
Co-related sub query is one in which inner query is evaluated only once and from that result outer
query is evaluated.
Nested query is one in which Inner query is evaluated for multiple times for gatting one row of
that outer query.