Question

In: Computer Science

1. Select all Course table data and display in primary key order. Show this query result.

Table Course:    Column    dataType Constraint

ccode char(8) primary key,

meetingTime char(4),

room char(6),

fid    decimal(3) NOT NULL,

cTitle    varchar(24) NOT NULL,

fee    decimal(4,2),   

prereq char(8)

1. Select all Course table data and display in primary key order. Show this query result.

2. By default MySQL runs in autocommit mode. Issue a START TRANSACTION command before a series of update commands that may need to be rolled back or to be committed. ROLLBACK will "undo" commands given in the transaction. [Note: COMMIT is not needed here, but makes work final and completes the transaction.]

Solutions

Expert Solution

1. The "order by" clause is used to order the result of a query by a particular column. The query for selecting all the course is :-

select * from courses order by ccode asc;

This query will select all the courses ordering them by ccode in ascending order. If we want to arrange the result in descending order we can use 'desc' in place of 'asc'.

2. To create transaction query we first of all need to start a transaction which can be done using the statement :-

start transaction;

Here after we have started the transaction we can perform any no. of sql statements that modify the database.

After we are done executing the statements we can either save those modifications or can completely remove them. For saving them we can use 'commit' statement and to remove those changes we can use rollback statement.

Eg :-

start transaction;

update Course set fee = fee + 100.00; -- This statement increases fees of all courses by 100

rollback; -- It will undo all the changes.

If we wanted to save the changes instead of undoing those changes then we could have used commit to do that.

 


Related Solutions

1. Write a query to: a. select data from INVOICES table as follows: Invoice date in...
1. Write a query to: a. select data from INVOICES table as follows: Invoice date in MM/DD/YYYY format Invoice Date in DD-Mon-YYYY format Invoice Total rounded to the nearest dollar Note: you can alias columns as you sit fit b. select data from VENDORS table as follows: Vendor Name Concatenate Vendor Name with the string ‘s Address Concatenate Vendor City, Vendor State and Vendor Zip Code (alias this) Your output should look like this (this is just an example of...
Write a query to display the columns listed below. For each customer the query should show...
Write a query to display the columns listed below. For each customer the query should show the current system date, the current day (when you do the problem the date and day will be different), the number of characters in the member last name, the last date the customer rented a video and how many total videos the person rented. /* Database Systems, 9th Ed., Coronel/MOrris/Rob */ /* Type of SQL : MySQL */ CREATE SCHEMA IF NOT EXISTS TINY_VIDEO;...
Choose all the optional query block in “Select “retrieval query? A. Select B. Where C. From...
Choose all the optional query block in “Select “retrieval query? A. Select B. Where C. From D. Order By A NULL value means A. Value missing B. Value unknown C. More than 1000 D. All the above Delete from DEF; /*DEF is a table/relation*/ What action does this command perform? A. Delete the table B. Delete all the rows from the table C. Deletes a column D. Deletes the top 10 tuples A attribute/column, fName, is of Data Type varchar(100)....
In the MedicalVisit table the primary key is defined as (Date, Doctor, Patient).     1. If the...
In the MedicalVisit table the primary key is defined as (Date, Doctor, Patient).     1. If the primary key were to be changed to (Doctor, Patient), how would it affect the design and information in the database?  (eg information structure in the database, normal form etc.) 2.  Please Draw an ER diagram based on the above original Relational Model
1. Write the statement that will display all of the information in the PetOwner table using...
1. Write the statement that will display all of the information in the PetOwner table using the asterisk (*) notation. 2. Write the statement that will display all of the information in the PetOwner table without using the asterisk (*) notation. 3. Write the statement that will display the first and last names of the owners in that order. 4. Write the statement to display the breed, type and DOB of all pets having a type of Cat. 5. Write...
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key,...
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key, origin_id integer, destination_id integer, foreign key (origin_id) references node(node_id), foreign key (destination_id) references node(node_id)); write an SQL query that lists all those nodes that have edges with a destination node that has color 'red'.
Which of the following is a Website query?Select all that apply.True False [Miami weather],...
Which of the following is a Website query?Select all that apply.True False [Miami weather],English (US) True False [Miami wikipedia.org],English (US) True False [Miami map],English (US) True False[Miami images], English (US)
Which of the following best describes the primary key? Select one: a. It's the encryption key...
Which of the following best describes the primary key? Select one: a. It's the encryption key that gets exchanged first with another party. b. It's the password that needs to be entered to open the database. c. It's the first item that is entered into the database on a screen. d. It's a field that uniquely identifies the record.
Use the data in Table 2.0, answer questions 1, 2, & 3. Please show all of...
Use the data in Table 2.0, answer questions 1, 2, & 3. Please show all of your working. Table 2.0 Data for a sample of 50 individual in a Cardiovascular Disease Study Participant ID Weight (kg) Height (cm) Smoking status Blood glucose 1 70 165 1 107 2 60 162 0 145 3 62 150 1 237 4 66 165 1 91 5 70 162 0 185 6 59 165 0 106 7 47 160 0 177 8 66 170...
1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint...
1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint 2.Use SQL to insert multiple records for each security classification with the same ID. You must have 4 classifications. 3.Use SQL to create 4 schemas, one for each security classification 4.Use SQL to create a view in each schema that restricts the records to those belonging to a particular security classification and restricts the columns to only those columns that have relevant data. 5.Select...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT