Documente Academic
Documente Profesional
Documente Cultură
3. Q. What is a join?
A. Join is a process of retrieve pieces of data from different sets
(tables) and returns them to the user or program as one “joinedâ€
collection of data.
cross-join
SELECT * FROM table1, table2;
self join
SELECT e1.name | |’ ‘ | | e2.ename FROM emp e1, emp e2 WHERE e1.
emp_no = e2.emp_no;
12. Q. Can a table have more than one foreign key defined?
A. A table can have any number of foreign keys defined. It can have
only one primary key defined.
13. Q. List all the possible values that can be stored in a BOOLEAN
data field.
A. There are only two values that can be stored in a BOOLEAN data
field:
-1(true) and 0(false).
15. Q. How many places to the right of the decimal can be stored in a
CURRENCY data field?
A. The CURRENCY data type can store up to four places to the right
of the decimal. Any data beyond the fourth place will be truncated by
Visual Basic without reporting an error.
21. Q. Which of the following WHERE clauses will return only rows
that have a NULL in the PerDiemExpenses column?
A. WHERE PerDiemExpenses <>
B. WHERE PerDiemExpenses IS NULL
C. WHERE PerDiemExpenses = NULL
D. WHERE PerDiemExpenses NOT IN (*)
A. C is correct � Two wildcards are used with the LIKE perator.
The underscore (_) stands for any one character of any case, and the
percent sign (%) stands for any number of characters of any case
including none. Because this string starts with an underscore rather
than a percent sign, it won't return Allen or Clark because they
represent zero and two characters before the "A". If the LIKE string
had been "%A%", both of these values would have been returned. David
was not returned because all non-wild card characters are case
sensitive. Therefore, only strings with an uppercase "A" as their
second letter are returned
23. Q. 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. SELECT DISTINCT City FROM Students;
26. Q. Write SQL SELECT example how you limiting the rows returned
with a WHERE clause.
27. Q. Write SQL SELECT query that returns the first and
last name of each instructor, the Salary,
and gives each of them a number.
A. SELECT FirstName, LastName, Salary,
ROWNUM FROM Instructors;
31. Q. Is the WHERE clause must appear always before the GROUP BY
clause in SQL SELECT ?
A. Yes.
The proper order for SQL SELECT
clauses is: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.
Only the SELECT and FROM clause are mandatory.
33. Q. Which operator do you use to return all of the rows from one
query except rows are returned in a second query?
A. You use the MINUS operator to return all rows from one query
except where duplicate rows are found in a second query. The UNION
operator returns all rows from both queries minus duplicates. The UNION
ALL operator returns all rows from both queries including duplicates.
The INTERSECT operator returns only those rows that exist in both
queries.
Answer: j and a aliases for table names. this is outer joint select
statament from two tables.
A. 1) The COUNT function tells you how many rows were in the result set.
SELECT COUNT(*) FROM TESTING.QA
2) The AVG function tells you the average value of a numeric column.
SELECT MAX(SALARY) FROM TESTING.QA
3) The MAX and MIN functions tell you the maximum and minimum value
of a numeric column.
SELECT MIN(SALARY) FROM TESTING.QA
4) The SUM function tells you the sum value of a numeric column.
SELECT SUM(SALARY) FROM TESTING.QA
On this page I put some SQL interview questions. These SQL interview questions are
very simple and mainly were used for interviewing software testers who is involved in
database SQL testing or grey box testing. You can find more SQL interview questions
searching the WEB.
A unique key has the property that no two values in the range are the same. A primary
key is chosen from among all the unique keys of a table to participate in referential
integrity constraints. Primary keys are unique by definition.
Primary key allows each row in a table to be uniquely identified and ensures that no
duplicate rows exist and no null values are entered.
Unique key constraint is used to prevent the duplication of key values within the rows of
a table and allow null values. (In oracle, one null is not equal to another null).
Primary Key:- Primary Key is an attribute or a set of attributes in a table which uniquely
identifies a record (row) in a table and no two records (rows) in the table can have the
same values for all the columns comprising the primary key.
Unique Key:- A unique key is a key which stores unique values (no duplicates) for that
particular column.
1. A Unique key can store a null value and primary key cannot store any null value.
Complex joins are joins which have following differences from a PK-FK joins
# Complex joins can have conditional mappings like >,<,>=,NOT, AND, etc apart from
'=' whereas the PK-FK joins are always '='.
# PK-FK joins are always (1-N), whereas complex joins can have (1 - 0,1) and (0,1 - N)
kind of relationships
complex join:- complex join are used in physical layer in between two tables where ever
that do not involved primary key and forgin key relationship.
Foregin Key:- by using the forgin key we can define the joins between two tables. joins
between is 1:M or M:M. if we want to define many: many relationship we have to use
bridge tables.
Primary keys enforce entity integrity by uniquely identifying entity instances. Foreign
keys enforce
referential integrity by completing an association between two entities.
Primary Key is unique Key entire the table and which is also NOT NULL
where as foriegn key is the null & which references the primary key .
The primary key is an attribute or a set of attributes that uniquely identify a specific
instance of an entity. Every entity in the data model must have a primary key whose
values uniquely identify instances of the entity.
To qualify as a primary key for an entity, an attribute must have the following
properties:
An example of an entity that could have several possible primary keys is Employee.
Let's assume that for each employee in an organization there are three candidate
keys: Employee ID, Social Security Number, and Name.
Name is the least desirable candidate. While it might work for a small department
where it would be unlikely that two people would have exactly the same name, it
would not work for a large organization that had hundreds or thousands of
employees. Moreover, there is the possibility that an employee's name could change
because of marriage. Employee ID would be a good candidate as long as each
employee were assigned a unique identifier at the time of hire. Social Security would
work best since every employee is required to have one before being hired.
Foreign Keys
A foreign key is an attribute that completes a relationship by identifying the parent
entity. Foreign keys provide a method for maintaining integrity in the data (called
referential integrity) and for navigating between different instances of an entity.
Every relationship in the model must be supported by a foreign key.
If the primary key of a child entity contains all the attributes in a foreign key, the
child entity is said to be "identifier dependent" on the parent entity, and the
relationship is called an "identifying relationship." If any attributes in a foreign key
do not belong to the child's primary key, the child is not identifier dependent on the
parent, and the relationship is called "non identifying."
Composite Keys
Sometimes it requires more than one attribute to uniquely identify an entity. A
primary key that made up of more than one attribute is known as a composite key.