A. SELECT date FROM dual;
B. SELECT date( );
C. SELECT getdate() FROM dual;
D. SELECT system_date;
The query SELECT getdate() FROM dual; will return current system date of our computer.
A. give one result per group.
B. cannot be used with ORDER By clause.
C. can output only one function in a query.
D. do not take arguments.
The aggregate functions operate on aggregate of tuples. The results of an aggregate function is a single value. Some of the aggregate functions that SQL includes are avg, min, max, sum etc.
A. characters * and _
B. characters * and %
C. characters % and _
D. characters * and %
In order for patterns to include the special pattern characters (that is, %, _), SQL allows the specific of an escape character. The escape character is used immediately before a special pattern character to indicate that the special pattern character is to be treated as a normal character.
A. SELECT * FROM tab1;
B. SELECT * FROM tab1 ORDER BY marks ;
C. SELECT * FROM tab1 ORDER BY ASCENDING;
D. SELECT * FROM tab1 SET ORDER ASC ;
To sort the results or a query in a specific order, we use ORDER BY clause. The ORDER BY clause allows sorting of query results by one or more columns. The sorting can be done either in ascending or descending order, the default order is ascending.
A. compare values in a condition.
B. combine the results of two conditions.
C. carry out arithmetic operations.
D. can carry out pattern matching.
To compare two values, a relational operator is used. The result of the comparison is true or false. The SQL recognizes following relational operators : =, >, <, >=, <=, <> (not equal to)
A. compare values in a condition.
B. combine the results of two conditions.
C. carry out arithmetic operations.
D. can carry out pattern matching.
The logical operators OR, AND and NOT are used to connect search conditions in the WHERE clause.
A. DISTINCT.
B. ALLOW REPEAT.
C. ALL.
D. NOT UNIQUE.
The DISTINCT keyword eliminates duplicate rows from the results of a SELECT statement.
A. not allow duplicate values in a column.
B. allow only one column in the table.
C. apply only to Primary key column.
D. allow only unique rows in a table.
Unique constraint ensures that no two rows have the same value in the specified column(s). This constraint can be applied only to columns that have also been declared NOT NULL, however, this condition is implementation dependent.
A. name of the table.
B. comment.
C. special keyword.
D. data type.
NULL is a special keyword in SQL that depicts an empty value. A column having NULL is not empty but stores an empty value. Two NULLs cannot be added, subtracted or compared.
A. number.
B. char.
C. date.
D. text.
The date data type stores year, month and day values.
A. data types and meanings.
B. keywords and meanings.
C. data about data.
D. list of data operations.
A data dictionary is a file that contains "metadata" i.e., "data about data".
A. SELECT and UPDATE.
B. SELECTand CREATE.
C. CREATE and DELETE.
D. GRANTand REVOKE.
Data control language (DCL) refers to the subgroup of SQL statements that controls access to database objects and data. These statements begin with one of the following keywords: GRANT, or REVOKE.
A. SELECT, INSERT and UPDATE.
B. CREATE, DROP and ALTER TABLE.
C. SELECT, INSERT and CREATE.
D. CREATE, INSERT and DROP.
The DDL provides a set of definitions to specify the storage structure and access methods used by the database system.
The ORDER BY clause allows you to impose an order on your output. Using this clause will display your query results in a sorted manner, by one or more columns. The sorting can be done either in ascending or descending order, ascending being the default order. When writing the query, it is generally placed last.
The example below –
SELECT name, marks
FROM student
ORDER BY marks;
displays output as –
NAME MARKS
Bina 60.5
Abhishek 65.5
Garima 78.8
Dhruv 79.5
Ankush 88.5
The output is in ascending order of marks.
SELECT * FROM student
ORDER BY name DESC;
The Primary Key uniquely identifies each row. It can not have NULL values or repeated values in it. A table can have only one Primary Key. When it is placed as a constraint on a column (or a set of columns), the column has to store values in keeping with these rules.
Example : CREATE TABLE student (rollno number (2) NOT NULL PRIMARY KEY,
name char(15), marks number(5,1), grade char(1), class char(5));
Data rows are added to a table using the INSERT command. INSERT command can also be used to take values from one table and add them to another. In place of the values clause, an appropriate query is given and the resulting rows are added into the target table.
Example :
FROM student WHERE marks>75;
Here, rows where marks > 75 will be considered from table STUDENT and the NAME and CLASS columns will be inserted into table TEMP.
To insert using a query, keep in mind that :
(i) Both the tables must be already created.
(ii)The columns of the tables being inserted into, must match the columns output by the sub query.
The Primary Key uniquely identifies each row. It can not have NULL values or repeated values in it. A table can have only one Primary Key. When it is placed as a constraint on a column (or a set of columns), the column has to store values in keeping with these rules.
Example : CREATE TABLE student (rollno number (2) NOT NULL PRIMARY KEY, name char(15), marks number(5,1), grade char(1), class char(5));
A new table can be created from an existing one by using the CREATE and SELECT statements in a query.
Example :
CREATE TABLE newtab AS ( SELECT EmpCode, ProjCode FROM employ WHERE Job = ‘Manager’);
Table newtab will have 2 columns, EmpCode and ProjCode, and data picked up from rows where Job was Manager, in the table employ. If the WHERE clause is left out, data from all the rows will be inserted.
CREATE TABLE employee (EmpCode number(4), EmpName varchar2(10), Job varchar2(10), Salary number(7,2), ProjCode varchar2(6));
The HAVING clause places conditions on groups in contrast to WHERE clause that places conditions on individual rows. While WHERE conditions cannot include aggregate functions, HAVING condition can do so.
This means you can not do some thing like the following-
SELECT Grade, MAX(marks) FROM student WHERE MAX(marks)>75 GROUP BY Grade;
WHERE would apply to individual rows like –
SELECT Grade, marks FROM student WHERE marks>75;
To see the maximum marks for each grade, if over 75, you would use the HAVING clause. The HAVING clause defines the criteria to select the output of certain groups.
SELET Grade, MAX (marks) FROM student GROUP BY grade Having MAX (marks)>75;
A view is a logical table that contains no data of its own. Its contents are taken from other tables through the execution of a query.The table on which a view is based is called a base table. Views are like windows through which you view information that is actually stored in a base table.
Advantages of using a VIEW –
1)Views display data selectively and so restrict access to data.
2)Views are used to get results of complicated queries, especially where multiple tables are used.
At times, you would like to see only certain rows according to your requirement instead of all the rows all the time. The WHERE clause lets you give a condition which restricts the rows.
While specifying the condition, operators are used. There are three types of operators –
¨
¨
¨
Relational Operators are used for comparison between two values.
|
Operator |
Meaning |
|
= |
Equal to |
|
> |
Greater than |
|
>= |
Greater than or equal to |
|
< |
Less than |
|
<= |
Less than or equal to |
|
<> |
Not equal to |
Example
SELECT * FROM student
WHERE marks>75;
Here, output rows will be selected based on the condition marks>75, > being a relational operator.
Logical Operators are used to combine two or more conditions to produce a single result. The conditions are evaluated to True or False and a row is considered only if the final result is True. Logical operators may also be used to negate the results of a single condition.
|
Operator |
Meaning |
|
AND |
Returns True if both component conditions are True |
|
OR |
Returns True if any one component condition is True |
|
NOT |
Returns True if the condition is False |
Example
SELECT * FROM student
WHERE grade=’A’ AND class='XII A';
Here, the first condition is grade = ‘A’ and the second condition is class='XII A'. The AND between them means that all the rows for which both conditions are true will be part of the result.
Example
SELECT * FROM student
WHERE grade=’A’ OR class='XII A';
Here, the first condition is grade = ‘A’ and the second condition is class='XII A’. The OR between them means that all the rows for which any one condition is true will be part of the result.
Example
SELECT * FROM student
WHERE NOT grade='A'
Here, the condition grade = ‘A’ is to be negated. The rows where grade is not ‘A’ are seen in the output.
Special operators are used to give other comparison conditions.
|
Operator |
Meaning |
|
BETWEEN … AND … |
Between two values (inclusive) |
|
IN (set) |
Match any value in the list |
|
LIKE |
Match a character pattern |
|
IS NULL |
Is a null value |
Using BETWEEN:- It displays rows based on a range of values.
Example
SELECT * FROM student
WHERE marks BETWEEN 75 AND 90;
The output will be rows that have the value for column marks between 75 and 90.
Using IN:- It tests for a value in a specified set of values.
Example
SELECT * FROM student
WHERE name IN(‘Brij’, ‘Dhruv’, ‘Anu’, ‘Surbhi’);
The output rows have the value in column name as one of those given in the list within parenthesis.
Using LIKE:- LIKE can be applied only to columns of CHAR datatype. LIKE searches character data to see if part of it matches a pattern . Two symbols are used to make the search string –
%(Percent) - it represents any sequence of zero or more characters.
_(Underscore) - it represents any single character
To look at the details of all students whose name starts with ‘A’ we can give –
SELECT * FROM student
WHERE name LIKE ‘A%’;
Here, we have specified only ‘A’ which may be followed by any character, as implied by the % sign.
To look at the details of all students whose name starts with an unknown letter but is followed by ‘aurav’ we can give –
SELECT * FROM student
A view is a logical table that contains no data of its own. Its contents are taken from other tables through the execution of a query. As the values in those tables change, so automatically, will the values in the view.
The table on which a view is based is called a base table. Views are like windows through which you view information that is actually stored in a base table.
Advantages of using a VIEW –
·
·
· One view can be used to display data from several tables.
Data Definition Language (DDL) is one of the major components of the Structured Query Language (SQL). It is used to create data structures like databases, tables, views and indexes. Some of the commands comprising DDL are CREATE TABLE, DROP TABLE and CREATE INDEX.
Data Manipulation Language (DML) is a category of SQL used to manipulate data – query, insert, update etc. Examples of DML commands are SELECT, INSERT, DELETE.
Data Control Language DCL is a subset of SQL, used to control access to data in a database. Examples of DCL commands include: GRANT - to allow specified users to perform specified tasks, REVOKE to cancel previously granted or denied permissions.
Data Definition Language (DDL) is one of the major components of the Structured Query Language (SQL). It is used to create data structures like databases, tables, views and indexes. Some of the commands comprising DDL are CREATE TABLE, DROP TABLE and CREATE INDEX.
Data Manipulation Language (DML) is a category of SQL used to manipulate data – query, insert, update etc. Examples of DML commands are : SELECT, INSERT, DELETE .
Data Control Language (DCL) is a subset of SQL, used to control access to data in a database. Examples of DCL commands include: GRANT - to allow specified users to perform specified tasks, REVOKE to cancel previously granted or denied permissions.
LIKE searches character data to see if part of it matches a pattern . The character pattern-matching operation is called wildcard search. Two symbols are used to make the search string –
% - it represents any sequence of zero or more characters.
_ - it represents any single character.
To look at the details of all students whose name starts with ‘A’ we can give:
SELECT *FROM studentWHERE name LIKE ‘A%’ ;
Output –
|
ROLLNO |
NAME |
MARKS |
GRADE |
CLASS |
|
2 |
Ankur |
88.5 |
A |
XII A |
|
3 |
Abhinav |
65.5 |
B |
XII A |
The query gives ‘A%’ as a pattern to match in column name - ‘A’ which may be followed by any character.
To look at the details of all students whose name starts with one unknown letter that is followed by ‘aurav’ we can give –
SELECT *FROM studentWHERE name LIKE ‘_aurav’;
Output –
|
ROLLNO |
NAME |
MARKS |
GRADE |
CLASS |
|
9 |
Gaurav |
78.8 |
A |
XII B |
|
11 |
Saurav |
77.7 |
B |
XII C |
The ORDER BY clause allows you to impose an order on your output. Using this clause, will display your query results in a sorted manner, by one or more columns. The sorting can be done either in ascending or descending order, ascending being the default order. When writing the query, it is generally placed last.
Example :–
SELECT name, marks FROM student ORDER BY marks;
Displays output as –
NAME MARKS
Brij 60.5
Abhinav 65.5
Gaurav 78.8
Dhruv 79.5
Ankur 88.5
The output is in ascending order of marks.
SELECT * FROM student ORDER BY name DESC;
Constraint is a restriction or a check that is applied to the columns of the table. They prevent invalid data entry into tables as the data they store must satisfy the checks or conditions placed. Constraints are specified when the table is defined. Constraints may be defined at the column level or the table level.
Some commonly used constraints that may be applied are –
NOT NULL - column cannot contain null values
UNIQUE - value must be unique in all rows
PRIMARY KEY - uniquely identifies each row
FOREIGN KEY - establishes a relationship between columns of different tables.
CHECK - gives a condition that must be true
CREATE TABLE student
(rollno number (2) NOT NULL PRIMARY KEY, name char(15),
marks number(5,1) CHECK (marks >25), grade char(1),
class char(5) DEFAULT = ‘KG’);
On giving this command, a table named STUDENT will be created. When data is entered, it will not allow BLANK OR duplicate values in ROLLNO column, marks should be greater than 25 and default value for class will be ‘KG’. Here, we have applied column level constraints.
To apply constraint to the table as a whole, put it at the end of the table definition.
CREATE TABLE employee (empcode number (4) NOT NULL,
name char(15), salary number(5,1), dept char(4),
joindate date, birthdate date, CHECK ( joindate > birthdate);
Aggregate functions are applied to all rows in a table or to a subset of the table specified by a WHERE clause. Aggregate functions produce a single value for the entire group of table entries. These functions are :
COUNT produces the number of rows.
SUM produces the arithmetic sum of all selected values of a given column.
AVG produces the average (mean) of all selected values of a given column.
MAX produces the largest of all selected values of a given column.
MIN produces the smallest of all selected values of a given column.
Aggregate functions are used like column names in the SELECT clause of queries. The functions SUM and AVG are used only with numeric columns. COUNT, MAX, MIN can be used with numeric, date or character.
The name of the column on which the function is to be applied, is placed within parenthesis. Give only one column within a pair of parenthesis at a time. To use more than one function, write them and separate them by commas. To apply the same function to many columns, repeat the function giving a different column name every time in the same statement.
Aggregate functions are applied to all rows in a table or to a subset of the table specified by a WHERE clause. Aggregate functions produce a single value for the entire group of table entries. These functions are :
At times, you would like to see only certain rows according to your requirement instead of all the rows all the time. The WHERE clause lets you give a condition which restricts the rows.
While specifying the condition, operators are used. There are three types of operators –
Relational Operators
Logical operators
Special operators
Relational Operators are used for comparison between two values.
|
Operator |
Meaning |
|
= |
Equal to |
|
> |
Greater than |
|
>= |
Greater than or equal to |
|
< |
Less than |
|
<= |
Less than or equal to |
|
<> |
Not equal to |
Example
SELECT * FROM student
WHERE marks>75;
Here output rows will be selected based on the condition marks>75, > being a relational operator.
Logical Operators are used to combine two or more conditions to produce a single result. The conditions are evaluated to True or False and a row is considered only if the final result is True. Logical operators may also be used to negate the results of a single condition.
|
Operator |
Meaning |
|
AND |
Returns True if both component conditions are True |
|
OR |
Returns True if any one component condition is True |
|
NOT |
Returns True if the condition is False |
Example:-
SELECT *FROM student
WHERE grade=’A’ AND class=’XII A’;
Here, the first condition is grade = ‘A’ and the second condition is class=’XII A’. The AND between them means that all the rows for which both conditions are true will be part of the result.
Example:-
SELECT * FROM student
WHERE grade=’A’ OR class=’XII A’;
Here, the first condition is grade = ‘A’ and the second condition is class=’XII A’. The OR between them means that all the rows for which any one condition is true will be part of the result.
Example:-
SELECT *FROM student
WHERE NOT grade=’A’ ;
Here, the condition grade = ‘A’ is to be negated. The rows where grade is not ‘A’ are seen in the output.
Special operators are used to give other comparison conditions.
|
Operator |
Meaning |
|
BETWEEN … AND … |
Between two values (inclusive) |
|
IN (set) |
Match any value in the list |
|
LIKE |
Match a character pattern |
|
IS NULL |
Is a null value |
Using BETWEEN
It displays rows based on a range of values.
Example:-
SELECT *FROM student
WHERE marks BETWEEN 75 AND 90;
The output will be rows that have the value for column marks between 75 and 90.
Using IN
It tests for a value in a specified set of values.
Example
SELECT *FROM student
WHERE name IN(‘Brij’, ‘Dhruv’, ‘Anu’, ‘Surbhi’);
The output rows have the value in column name as one of those given in the list within parenthesis.
Using Like
LIKE can be applied only to columns of CHAR datatype. LIKE searches character data to see if part of it matches a pattern . Two symbols are used to make the search string –
% - it represents any sequence of zero or more characters.
_ - it represents any single character
To look at the details of all students whose name starts with ‘A’ we can give –
SELECT *FROM student
WHERE name LIKE ‘A%’;
Here, we have specified only ‘A’ which may be followed by any character, as implied by the % sign.
To look at the details of all students whose name starts with an unknown letter but is followed by ‘aurav’ we can give –
SELECT *FROM student
WHERE name LIKE ‘_aurav’;
Constraintis a restriction or a check that is applied to the columns of the table. They prevent invalid data entry into tables as the data they store must satisfy the checks or conditions placed. Constraints are specified when the table is defined. Constraints may be defined at the column level or the table level.
Some commonly used constraints that may be applied are –
NOT NULL - column cannot contain null values
UNIQUE - value must be unique in all rows
PRIMARY KEY - uniquely identifies each row
FOREIGN KEY - establishes a relationship between columns of different tables.
CHECK - gives a condition that must be true.
CREATE TABLE student
(rollno number (2) NOT NULL PRIMARY KEY,
name char(15),
marks number 5,1)
CHECK (marks >25),
grade char(1),
class char(5) DEFAULT = ‘KG’);
On giving this command, a table named STUDENT will be created. When data is entered, it will not allow BLANK OR duplicate values in ROLLNO column, marks should be greater than 25 and default value for class will be ‘KG’. Here, we have applied column level constraints.
To apply constraint to the table as a whole, put it at the end of the table definition.
CREATE TABLE employee
(empcode number (4) NOT NULL,
name char(15), salary number(5,1),
dept char(4),
joindate date,
birthdate date,
CHECK ( joindate > birthdate);
A. outputs 1 if any input is 1.
B. outputs 1 only if all inputs are 1.
C. outputs 0 if any input is 0.
D. outputs 0 if all inputs are 1.
The OR gate has two or more input signals but only one output signal. If any of the input signals is 1, the output signal is 1.
A. DISTINCT.
B. NO REPEAT.
C. DEFAULT.
D. NOT UNIQUE.
The DISTINCT keyword eliminates duplicate rows from the results of a SELECT statements.The syntax is:- SELECT DISTINCT city FROM Suppliers;
A. number.
B. char.
C. date.
D. text.
To store alphanumeric text such as letters, numbers, spaces, symbols and punctuation, use the Character data type.
A. DDL.
B. DCL.
C. DML.
D. TCL.
Individual SQL statements are declarative as they describe what the program should accomplish.
A. Data Control Language.
B. Data Convert Language.
C. Dynamic Control Language.
D. Dynamic Convert Language.
It is a computer language which is used to control the access to data in a database. The examples of DCL Commands are: GRANT and REVOKE.
A. Data Markup Language.
B. Data Manipulation Language.
C. Dynamic Markup Language
D. Dynamic Mapping Language.
It is used to insert, delete and update data in database.
A. Dynamic Data Language.
B. Data Delimiting Language.
C. Data Definition Language.
D. Detailed Data Language.
DDL is a computer language for defining data structures. The result of compilation of DDL statements is a set of tables which are stored in a special file called data dictionary (or directory).
A. Simple Questioning Language.
B. Sequential Query Language.
C. Simple Query Language.
D. Structured Query Language.
It is a database computer language designed for managing data in relational database mangement system.
A. list of values.
B. list of commands.
C. list of NULL.
D. none of these.
In SOL, there are different operators that you can use in the expressions. IN opearator is used to find out the list of values.It selects values that match any value in a given list of values.
A. data types and meanings.
B. keywords and meanings.
C. data about data.
D. list of data operations.
Data dictionary is a "centralised repository of information about data such as meaning, relationships to other data, origin, usage and format." Data dictionary is the file that contains "metadata". i.e., data about data.
A. table that physically exists.
B. physical table, where trigger and index can be defined.
C. virtual table, where trigger and index can be defined.
D. virtual table, where trigger and index can not be defined.
A SQL view is a virtual table, which is based on SQL SELECT query.It does not really exist in its own right but is instead derived from one or more underlying base tables.
A. A table can have only one column with unique values.
B. There can be only one Primary Key for a table.
C. By default output is displayed in ascending order.
D. Aggregate functions work on individual rows.
The primary key of a relational table is unique, which identifies each record in a table. There cannot be more than one primary key in a table.
A. MODIFY command.
B. ALTER STRUCT command.
C. TABLE command.
D. ALTER TABLE command.
The ALTER TABLE statement allows you to rename an existing table. It can also be used to add, modify or drop a column from an existing table.
A. SELECT * from item ;
B. SELECT name, price from item ;
C. SELECT name, price from table item ;
D. SELECT name, price from tablename item ;
Here, 'name' and 'price' are the column names and 'item' is the name of the table.
A. data can be discarded easily.
B. constraints can be discarded.
C. data can be displayed selectively.
D. data can be viewed in sequence.
The main advantage of using view is that it increases the accessing speed, as data can be displayed selectively.
A. Dynamic Data Language.
B. Data Delimiting Language.
C. Data Definition Language.
D. Detailed Data Language.
The DDL (Data Definition Language) provides a set of definitions to specify the storage structure and access methods used by the database system. It provides statements for the creation and deletion of tables and indexes.
Only one column appears as || is the concatenation operator.
A. it must be completely filled.
B. it should have some data.
C. it should have data in one row and one column.
D. it must be empty.
The DROP table command of SQL lets us drop a table from the database. The SQL requires us to empty a table before we eleminate from the database. But there is a condiiton for dropping a table ; it must be an empty table.
A. SELECT avg(salary) FROM employee WHERE (grade='E2' OR grade='E4');
B. SELECT avg(salary WHERE (grade='E2' OR grade='E4');
C. DISPLAY avg(salary) FROM employee WHERE (grade='E2' OR grade='E4');
D. SELECT avg(salary) FROM employee HAVING (grade='E'’ AND grade='E4');
AVERAGE is an aggregate function used in SQL and is used with WHERE clause.
A. it has only one column.
B. it does not have Primary Key.
C. it is empty.
D. it does not have null values.
To remove all the rows from the table, we use DELETE command. A table with rows in it cannot be dropped.
SELECT COUNT(EmpName)
FROM Employee
WHERE Job = ‘Clerk’ ;
Null is a keyword implying an empty value. Two NULLs cannot be added, subtracted or compared. A NULL can not be equated with 0 or blank spaces.
To use it in a query, write it as given below –
SELECT *
WHERE grade IS NULL;
LIKE searches character data to see if any part of it matches a pattern. The character pattern-matching operation is called wildcard search. Two symbols are used to make the search string–
%(Percent) - it represents any sequence of zero or more characters.
_(Under Score) - it represents any single character.
To look at the details of all students whose name starts with ‘A’, we can give:
SELECT * FROM student
WHERE name LIKE ‘A%’ ;
Output –
|
ROLLNO |
NAME |
MARKS |
GRADE |
CLASS |
|
2 |
Ankur |
88.5 |
A |
XII A |
|
3 |
Abhinav |
65.5 |
B |
XII A |
The query gives ‘A%’ as a pattern to match in column name - ‘A’ which may be followed by any character.
To look at the details of all students whose name starts with one unknown letter that is followed by ‘aurav’, we can give –
SELECT * FROM student
WHERE name LIKE ‘_aurav’;
Output –
|
ROLLNO |
NAME |
MARKS |
GRADE |
CLASS |
|
9 |
Gaurav |
78.8 |
A |
XII B |
|
11 |
Saurav |
77.7 |
B |
XII C |
SELECT COUNT(EmpName)
FROM Employee
where Job = ‘Clerk’;
SELECT EmpName, ' is on Project ', ProjCode FROM emp;
Null is a keyword implying an empty value. Two NULLs cannot be added, subtracted or compared. A NULL can not be equated with 0 or blank spaces. To use in query, write it as given below –
SELECT * FROM student
A Data Dictionary is a database containing data about all the databases and objects therein, that make up a database system. It is often thought of as “data about the data” or “metadata”.
SELECT EmpName, 'is on Project', ProjCode FROM emp;
INSERT INTO employee (EmpCode, EmpName, Job, Salary, ProjCode) VALUES(‘A101’, ‘Shyam’, ‘Clerk’, 5000, 'LUC222');
They are as follows:-
count() – is a function to count, non null values in a column.
count(*) – to count the number of rows in a table.
count(code) – to count the number of Non-null values in column code .
count(DISTINCT dept) - to count the number of distinct entries, i.e. to count a particular entry only once even if it appears many times.
count(ALL dept) – to count the number of non-null values in column dept, i.e. counting repetitions too.
Only empty tables can be deleted. We can remove the entire table and once removed, the table cannot be retrieved. The command to remove the table student permanently from the database is :
DROP TABLE student;
The HAVING clause places conditions on groups in contrast to WHERE clause that places conditions on individual rows. While WHERE conditions cannot include aggregate functions, HAVING condition can do.
EXAMPLE:-
SELET Grade, MAX (marks) FROM student GROUP BY grade Having MAX (marks) >75;
A Data Dictionary is a database containing data about all the databases and objects therein, that make up a database system. It is often thought of as “data about the data” or “metadata”.
A new table can be created from an existing one by using the CREATE and SELECT statements in a query. Example :
CREATE TABLE newtab AS
(
SELECT EmpCode, ProjCode FROM employ WHERE Job = ‘Manager’
);
Data rows are added to a table using the INSERT command. INSERT command can also be used to take values from one table and add them to another. In place of the values clause, an appropriate query is given and the resulting rows are added into the target table.
Example :
INSERT INTO temp
SELECT name, class
FROM student
WHERE marks>75;
Here, rows where marks > 75 will be considered from table STUDENT and the NAME and CLASS columns will be inserted into table TEMP.
To insert using a query, keep in mind that :
(i) Both the tables must be already created.
(ii)The columns of the tables being inserted into, must match the columns output by the sub query.
INSERT INTO employee (EmpCode, EmpName, Job, Salary, ProjCode) VALUES (‘A101’, ‘Shyam’, ‘Clerk’, 5000, 'LUC222’);
The functions can be distinguished as follows:
CREATE TABLE employee
(EmpCode number(4), EmpName char(10),
Job char(10), Salary number(7,2),
ProjCode char(6));
We can not delete a table until it is empty as we can delete only empty tables. We can remove the entire table using DROP TABLE command. Once a table is removed, it cannot be retrieved. The command to remove the table student permanently from the database is:
DROP TABLE student;
The HAVING clause places conditions on groups in contrast to WHERE clause that places conditions on individual rows. While WHERE conditions cannot include aggregate functions, HAVING condition can do so.
This means we can not do some thing like the following-
SELECT Grade, MAX(marks)
FROM student
WHERE MAX(marks)>75
GROUP BY Grade;
WHERE would apply to individual rows like –
SELECT Grade, marks
FROM student
WHERE marks>75 ;
To see the maximum marks for each grade, if over 75, you would use the HAVING clause. The HAVING clause defines the criteria to select the output of certain groups.
SELET Grade, MAX(marks)
FROM student
GROUP BY grade
The HAVING clause places conditions on groups in contrast to WHERE clause that places conditions on individual rows. While WHERE conditions cannot include aggregate functions, HAVING condition can.
SELET Grade, MAX (marks)
FROM student
GROUP BY grade
A. Unary decision
B. Ternary decision
C. Binary decision
D. redundant decision
Binary decision results either into YES(TRUE) or the NO(FALSE). There are only two possible answers.
A. Constant
B. Literals
C. Qualifier
D. None of these
Boolean Expression is combination of variables and complement of variables.A single variable or complement of variable is known as Literal.
A. F=xy.
B. F=x+y.
C. F=x’.
D. F=x+y’.z.
F(x,y,z)= x+y’.z can generate AND, OR and NOT functions. Therefore, this expression is algebraically complete.
A. a Boolean element.
B. a complement of boolean variable.
C. a notation for representing a fixed value in source code.
D. an actual understanding of Boolean expression.
A literal is some specific piece of data, taken literally from a computer system.
A. first distributive law of Boolean algebra is not available in the ordinary algebra.
B. first indempotent law of Boolean algebra is not available in the ordinary algebra.
C. second distributive law of Boolean algebra is not available in the ordinary algebra.
D. first commutative law of Boolean algebra is not available in the ordinary algebra.
The distributive law states that: X.(Y+Z) = X.Y +X.Z and X+Y.Z = (X+Y).(X+Z).The second distributive law of the Boolean algebra is not available in the ordinary algebra.
A. (X’)’ = X’.
B. (X’) = X.
C. (X)’ = X.
D. (X’)’ = X.
If X = 1, then X’ = 0
A. P’QR + P’QR’ + P’Q’R + PQR’ +P’Q’R’.
B. P’Q’R + P’QR’ + P’Q’R + PQR’ +P’Q’R’.
C. P’QR + P’Q’R’ + P’Q’R + PQR’ +P’Q’R’.
D. P’QR + P’QR’ + P’Q’R + P’QR’ +P’Q’R’.
P+QR’
= P’[Q+Q’][R+R’] + QR’[P+P’]
A. X+X = X’ and X.X = X.
B. X+X = X and X.X = X.
C. X+X = X and X.X = X’.
D. X+X = X’ and X.X = X’.
If X = 1, then
X + X = 1 + 1 = 1 = X
X.X = 1.1 = 1 = X.
A. commutative law.
B. DeMorgan’s law.
C. associative law.
D. logical law.
In formal logic, De Morgan's laws are rules relating the logical operators "and" and "or" in terms of each other via negation, namely:
NOT (P OR Q) = (NOT P) AND (NOT Q)
NOT (P AND Q) = (NOT P) OR (NOT Q).
A. y(w+x).
B. w(x+y).
C. x(w+y).
D. xy’+w.
F = y(wz’ + wz) + xy = yw(z+z’) + xy
A. PQR + PQ’R + PQR’ + PQ’R’ + P’Q’R’.
B. P’Q’R + PQ’R + PQR’ + PQ’R’ + P’Q’R’.
C. PQ’R + PQ’R + PQR’ + PQ’R’ + P’Q’R’.
D. PQR’ + PQ’R + PQR’ + PQ’R’ + P’Q’R’.
P+Q’R = P(Q+Q’)(R+R’)+Q’R(P+P’)
A. nn
B.
C. 10n
D. 22n
The number of rows in the truth table is 2n ,i.e., 2 raise to the power of input binary variable.
A.
.
B.
.
C.
.
D.
.
Using duality principle, changing (+) to (.) and vice-versa and by replacing 0’s with 1’s and1’s with 0’s, the dual of the expression can be obtained.
A. absorption.
B. indempotence.
C. involution.
D. duality.
Any algebraic equality is derived from the axioms of Boolean algebra remains true when the operators OR and AND are interchanged and identity elements 0 and 1 are interchanged. This property is known as duality principle.
A. binary decision.
B. logical decision.
C. compound decision.
D. symbolic decision.
A decision between only two alternatives is called binary decision.
A. Commutative law.
B. Associative law.
C. Distributive law.
D. DeMorgan’s law.
The above expression is a distributed law, which can be proved with the help of truth tables. Both columns X(Y+Z) and XY+YZ in the truth table will be identical.
A. x+y.
B. xy.
C. x’y.
D. xy’.
The above expression can be simplified by using the DeMorgan’s first theorem :(A+B)' = A'.B'
A. A’B’CD.
B. A+B+C’+D’.
C. (A’+B).(C+D).
D. (A+B’).(C+D).
This can be proved by using DeMorgan’s first and second law.
A. an absorption law.
B. a distributive law.
C. a complemetary law.
D. a commutative law.
The expression can be proved with the help of truth table. The values of X AND X+XY are the same and this law is known as Absorption Law.
A. idempotence law.
B. involution law.
C. commutative law.
D. associative law.
It is involution law as it is stated, firstly by inverting the expression and then inverting it all over again. For example - ((A')') = A
A. XOR GATE.
B. XNOR.
C. NXOR.
D. NOR.
Combination of XOR and NOT is XNOR. In this, inputs must have an even number of 1’s to get a 1 (high) output.
A. venn diagram.
B. truth table.
C. veitch diagram.
D. K-map.
Venn diagrams or set diagrams, developed by John Venn, show all hypothetically possible logical relation between a finite collection of sets.
A. canonical group.
B. redundant group.
C. octet group.
D. quad group.
Redundant group is a group in which all 1’s are overlapped by pairs, quads, octets. The removal of redundant group leads to much simpler expression.
A. pair.
B. quad.
C. octet.
D. triplet.
To reduce Boolean expression, adjacent 1’s are encircled. If, 2 adjacent 1’s are encircled, then it makes a pair.
A. maxterm.
B. minterm.
C. non-canonical expression.
D. veitch diagram.
Veitch diagram is also known as karnaugh maps. Karnaugh map is nothing but a rectangle made up of certain number of squares, each square representing a Maxterm or Minterm.
A. gate.
B. quad.
C. redundant group.
D. bus.
The bus carries signals, which are in the form of 0’s and 1’s.
A. AND gate.
B. OR gate.
C. NOT gate
D. NAND gate.