cmsc127 3 Mysql PDF
cmsc127 3 Mysql PDF
2 Database Commands
CMSC127
You can check to see that this statement worked by executing the
After design, the first step in creating a database is, logically enough, command
to tell MySQL that we want to create a new database show databases;
We do this with the CREATE DATABASE SQL statement, as follows: You should now see the employee database listed among the
create database employee; databases in the system.
We now have an empty database, waiting for some tables to be
created.
You can check whether the tables in your database have been set up You can get more information about the structure of each table by
correctly using the command using the describe command, for example,
show tables; describe department;
Float Double
Char Char
When CHARs are stored, they will always be the exact length you
Obviously, storing a CHAR takes up more space on disk than storing
specify.
an equivalent variable-length string.
This is achieved by padding the contents of the column with spaces.
The trade-off is that it is faster to retrieve rows from a table in which
These spaces are automatically stripped when the contents of a all the columns are of fixed widths (that is, CHAR, numeric, or date).
CHAR column are retrieved.
The TEXT types are used for storing longer pieces of text than you
VARCHAR stores variable-length strings. can fit in a CHAR or VARCHAR.
You specify the width in parentheses after the type, for example, BLOB stands for Binary Large OBject.
VARCHAR(10). These types are the same except that BLOBs are intended to store
The range is 0 to 255. binary data rather than text.
Comparisons on BLOBs are case sensitive, and on TEXTs, they are
not.