Home
11.
What happens to system variables when resetis called? For example, is @ARGV reset when reset is passed "A"?

The reset function affects all variables, including system variables. For this reason, you should be careful when you use reset

12.
Does the following CREATE TABLE statement work? If not, what needs to be done to correct the problem(s)? Are there limitations as to what database implementation it works in (MySQL, Oracle, or SQL Server)?
CREATE       TABLE EMPLOYEE_TABLE AS:
( SSN              NUMBER(9)             NOT NULL,
LAST_NAME          VARCHAR2(20)          NOT NULL,
FIRST_NAME         VARCHAR(20)           NOT NULL,
MIDDLE_NAME        VARCHAR2(20)          NOT NULL,
ST ADDRESS         VARCHAR2(20)          NOT NULL,
CITY               CHAR(20)              NOT NULL,
STATE              CHAR(2)               NOT NULL,
ZIP                NUMBER(4)             NOT NULL,
DATE HIRED         DATE);

The CREATE TABLE statement does not work because there are several errors in the syntax. The corrected statement follows and is given as an Oracle-specific version. A listing of what was incorrect follows a corrected statement.

CREATE     TABLE   EMPLOYEE_TABLE
( SSN              NUMBER()        NOT NULL,
LAST_NAME          VARCHAR2(20)    NOT NULL,
FIRST_NAME         VARCHAR2(20)    NOT NULL,
MIDDLE_NAME        VARCHAR2(20),
ST_ADDRESS         VARCHAR2(30)    NOT NULL,
CITY               VARCHAR2(20)    NOT NULL,
STATE              CHAR(2)         NOT NULL,
ZIP                NUMBER(5)       NOT NULL,
DATE_HIRED         DATE );

The following needs to be done:
1. The AS: should not be in this CREATE TABLE statement.
2. A comma is missing after the NOT NULL for the LAST_NAME column.
3. The MIDDLE_NAME column should be NULL because not everyone has a middle name.
4. The column ST ADDRESS should be ST_ADDRESS. With two words, the database looked at ST as being the column name, which would make the database look for a valid data type, where it would find the word ADDRESS.
5. The CITY column works; although, it would be better to use the VARCHAR2 data type. If all city names were a constant length, CHAR would be okay.
6. The STATE column is missing a left parenthesis.
7. The ZIP column length should be (5), not (4).
8. The DATE HIRED column should be DATE_HIRED with an underscore to make the column name one continuous string.

13.
Can you drop a column from a table?

Yes. However, even though it is an ANSI standard, you must check your particular implementation to see if it has been accepted.

14.
What statement would you issue to create a primary key constraint on the preceding EMPLOYEE_TABLE?
ALTER TABLE EMPLOYEE_TBL
ADD CONSTRAINT EMPLOYEE_PK PRIMARY KEY(SSN);

15.
What statement would you issue on the preceding EMPLOYEE_TABLE to allow the MIDDLE_NAME column to accept NULL values?

ALTER TABLE EMPOYEE_TBL
MODIFY MIDDLE_NAME VARCHAR(20), NOT NULL;

16.
What statement would you use to restrict the people added into the preceding EMPLOYEE_TABLE to reside only in the state of New York ('NY')?

ALTER TABLE EMPLOYEE_TBL
ADD CONSTRAINT CHK_STATE CHECK(STATE=‘NY’);

17.
What statement would you use to add an auto-incrementing column called 'EMPID' to the preceding EMPLOYEE_TABLE using both the MySQL and SQL Server syntax?

ALTER TABLE EMPLOYEE_TBL
ADD COLUMN EMPID INT AUTO_INCREMENT;

18.
True or false: Normalization is the process of grouping data into logical related groups.

True.

19.
True or false: Having no duplicate or redundant data in a database and having everything in the database normalized is always the best way to go.

False. Not always; normalization can and does slow performance because more tables must be joined, which results in more I/O and CPU time.

20.
True or false: If data is in the third normal form, it is automatically in the first and second normal forms.

True.