click below
click below
Normal Size Small Size show me how
SQL
Question | Answer |
---|---|
Which SQL Sublanguage does this line of code call under? ALTER TABLE EMPLOYEES ADD email_address VARCHAR(100); | DDL Data Definition Language (DDL) Statements |
SQL: NF & RI Which normal form is this schema representing? Tables: Students | StudentCourse | Courses | 2nd Normal Form |
SQL: NF & RI Which normal form is this schema representing? Tables: Students | StudentCourse | Courses | Teachers | 4th Normal Form |
SQL: NF & RI Which normal form is this schema representing? Columns: ID | Student Name | Martial Status | Course Title | 1st Normal Form |
The SQL UPDATE can statement can | update multiple rows at a time |
What is SQL injection? | Injecting a SQL Statement as user input |
What is the purpose of AND and OR? | They connect multiple WHERE clauses together to restrict results |
What is the difference between WHERE and HAVING? | WHERE clause is used while fetching data. HAVING clause is used later to filter grouped data |
What is a primary key? | A column or group of columns that uniquely identify a row |
What is a foreign key? | A column, or columns, that references a column of another table to establish a relationship between rows |
What is the difference between ORDER BY and GROUP BY? | ORDER BY is used for sorting results, whereas GROUP BY is used with aggregate functions to group results |
How do you add a column to a table? | ALTER TABLE table_name ADD column_name datatype; |
Table: promotions PROMO_ID | PROMO_CATEGORY | PROMO_SUBCATEGORY | SELECT promo_category FROM promotions INTERSECT SELECT promo_category FROM promotions WHERE promo_subcategory <> 'discount'; SELECT promo_category FROM promotions MINUS SELECT promo_category FROM promotions WHERE promo_subcategory = 'discount'; |
With SQL, how can you insert a new record into the "Persons" table? | INSERT INTO Persons VALUES ('Jimmy', 'Jackson'); |
With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"? | SELECT * FROM Persons WHERE FirstName = 'Peter' AND LastName = 'Jackson'; |
With SQL, how can you delete just the records where the "FirstName" is "Peter" in the Persons Table? | DELETE FROM Persons where FirstName = 'Peter'; |
With SQL, how can you return the number of records in the "Persons" table? | SELECT COUNT(*) FROM Persons; |
Insert is a part of this sublanguage? | DML Data Manipulation Language (DML) Statements DQL DCL TCL |
DML statements include commands like CREATE, DROP, and ALTER | false |
Which normalized form introduces the concept of enforcing primary keys and removing composite columns? | First |
Which normalized form introduces the concept of removing duplicate data and creating separate tables for information? | Second |
Which of the following SQL datatypes is best used to represent a decimal number? | NUMERIC |
Use the AS keyword to specify an alias | true |
What JDBC object is used to reference the row returned by a query? | ResultSet |
Which of the following is not a component/class of JDBC API? | Transaction Transaction is not a class of JDBC API. Consists of following interfaces and classes: DriverManager, Driver, Connection, Statement, ResultSet, and SQLException |
The isolated property of a database transaction means | Concurrent transactions provide the same results that would be found if transactions were executed one-by-one |
The consistent property of a database transaction means | Any transaction will leave the data in a consistent state and rollback if the transaction fails |
In the context of the JDBC; the method next() does what? | It is used to iterate through a ResultSet |
JDBC Exceptions: JDBC statements throw which exception(s) | SQLException |
In a prepared statement, data is replaced with | question marks |
Which is used to execute stored procedures? | CallableStatement |
It's not necessary to call the close() method on a connection, it does not consume resources unless it is being actively used | false |
select * from employees; | get all the records from the "Employees" table and include all columns in the results |
select count(*) from city where population > 100000; | return the number of cities that have a population that is larger than 100,000 |
create table employees ( emp_id < > primary key , first_name < > not null , middle_name < > not null , last_name < > not null , last_worked < > not null , emp_photo < > ); | integer, varchar(50, char, varchar(50), timestamp, blob |
Four transaction properties | Atomicity Consistent Isolated Durability |
Durability property of a database transaction means | After a transaction successfully completes, changes to data persist and are not undone, even in the event of a system failure. |
Atomicity property of a database transaction means | All changes to data are performed as if they are a single operation. That is, all the changes are performed, or none of them are. |