Create a SQL batch file (createdb.sql) with the following code:
CREATE TABLE Friend (
firstname VARCHAR(15),
lastname VARCHAR(20),
city VARCHAR(15),
state CHAR(2),
age INTEGER
);
INSERT INTO Friend VALUES (
'Mike',
'Nichols',
'Tampa',
'FL',
19
);
INSERT INTO Friend VALUES (
'John',
'Wayne',
'Tampa',
'FL',
20
);
Run mysql -ucs655 -pabc123 cs655 < createdb.sql
where -u stands for the user, -p for the password, and cs655 for
the database name respectively.
To drop a table, you can use the following SQL batch file
(droptable.sql) and
run mysql -ucs655 -pabc123 cs655 < droptable.sql.
where droptable is a file contans a line "drop table Friend;".
For the Oracel database users, log into tinman and run
those batch files without first two lines in this way: sqlplus username/password < createdb.sql.
To load data file into a table, use the load command. For
example, LOAD DATA LOCAL INFILE "Corvettes.tb" INTO TABLE Corvettes
where the data in the file Corvettes.tb is loaded into
the table Corvettes.
For more information, please refer to
3.3.3 Loading Data into a Table of the manual of MySQL.
Note: If the table name has been taken, use another one. Table names are
case-senstive in MySQL.
Some useful MySQL DBMS commands:
To use MySQL DBMS, mysql -ucs655 -pabc123.
To show databases, show databases;.
To select a database named cs655, use cs655;.
To show tables in a database, show tables;.
To show the description of a table name Friend, describe Friend;.