Professional Documents
Culture Documents
MySQL Tutorial
MySQL Tutorial
1 of 3
http://www.cs.utexas.edu/~mitra/csSpring2012/cs327/lectures/mysql.html
MySQL Tutorial
Connecting to MySQL
In order to connect to the MySQL database server you must change directory to the z server.
> cd /u/z/users/cs327e/userName
Replace the word userName in the command with your own user name. The system will respond by asking
for your password:
Enter password:
Enter your MySQL password and press the Enter key. Your MySQL password has been given to you and it is
different from your CS account password. You will not see any entry as you type your password. If your
password is accepted you will see the MySQL prompt.
mysql>
The quotation marks are necessary within the parentheses. You can use this to change your password any
time later on if you need to.
You must select the database each time you want to use the database. The command to issue is:
mysql> use cs327e_s12_userName;
Commands need not be given on a single line. But be sure to end the command with a semi-colon. To cancel
a command use \c;
25-10-2012 7:39
MySQL Tutorial
2 of 3
http://www.cs.utexas.edu/~mitra/csSpring2012/cs327/lectures/mysql.html
mysql> SELECT
-> USER()
-> \c;
Creating Tables
To see the tables in your database do:
mysql> show tables;
Deleting a Table
Use the DROP TABLE command to delete a table:
mysql> DROP TABLE student;
25-10-2012 7:39
MySQL Tutorial
3 of 3
http://www.cs.utexas.edu/~mitra/csSpring2012/cs327/lectures/mysql.html
BIGINT
NUMBER(19,0)
CHAR
CHAR
DATE
DATE
DATETIME
DATE
DECIMAL
FLOAT(24)
DOUBLE
FLOAT(24)
FLOAT
FLOAT
INT
NUMBER(10, 0)
INTEGER
NUMBER(10, 0)
NUMERIC
NUMBER
REAL
FLOAT(24)
SMALLINT
NUMBER(5,0)
TIME
DATE
TIMESTAMP
DATE
VARCHAR
VARCHAR2
YEAR
NUMBER
The script should run and create a table called Name and populate that with data.
25-10-2012 7:39