Module 2: Defining a Database


1.  

Which TABLE type is the MySQL DEFAULT?

2.  

Which data types would you use to display the Date in one column and the Time in a separate column?

3.  

How does the VARCHAR data type differ from the CHAR data type?

4.  

What are the two main rules for naming a TABLE?

5.  

What is the syntax to create a database called Angel and a table in it called Wesley with a TINYINT column called Fred ?

6.  

How do you display the databases in your MySQL Server?

7.  

How do you display the tables in a database called Jet ?

8.  

How do you display the layout or specifications of a table called Wraith if you are already using the database in which it is housed?

9.  

How do you display the contents of a table called horse if you are already using the database in which it is housed?

10.  

If the horse table has the columns bridle , saddle , and blanket , how do you display the contents of saddle only?

Answers

1.  

The MySQL DEFAULT TABLE type is MyISAM.

2.  

The one column would be defined as the DATE type and the other column would be defined as the TIME type.

3.  

Both CHAR and VARCHAR have an defined limit to the length of string value they may hold, but the VARCHAR data type varies in length if the string value placed in it is shorter than the defined limit. The CHAR data type is always the length of its defined limit.

4.  

The two main rules for naming a table are:

  1. A Table name may only have up to 64 characters

  2. A Table name may not include characters backslash ( \ ), forward slash ( / ) or period ( . ).

5.  

The following is the syntax to create a database called Angel and a table in it called Wesley with a TINYINT column called Fred :

 CREATE DATABASE Angel; USE Angel; CREATE TABLE Wesley( Fred TINYINT) TYPE=MyISAM; 

6.  

To display the databases in your MySQL Server, use the command SHOW DATABASES; .

7.  

To display the tables in a database called Jet , use the following syntax:

 USE Jet;SHOW TABLES; 

or

 SHOW TABLES FROM Jet; 

8.  

To display the layout or specifications of a table called Wraith if you are already using the database in which it is housed, use the command DESC Wraith; .

9.  

To display the contents of a table called horse if you are already using the database in which it is housed, use the command SELECT * FROM horse;

10.  

To display only the saddle column in the horse table, use the command SELECT saddle FROM horse;




MySQL(c) Essential Skills
MySQL: Essential Skills
ISBN: 0072255137
EAN: 2147483647
Year: 2006
Pages: 109

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net