Basic commands on mysql command line:
% mysql
mysql> SHOW DATABASES;
mysql> USE wbluhm;
mysql> SHOW TABLES;
mysql> CREATE TABLE dummy ( first_name CHAR(20) , last_name CHAR(20) );
mysql> SHOW TABLES;
mysql> DESCRIBE dummy;
mysql> DROP TABLE dummy;
mysql> SHOW TABLES;
mysql> exit;
Creating tables from .sql scripts
SQL script example: create_books.sql
-- creates the table books in database wbluhm
CREATE TABLE books
(
title CHAR(50) NOT NULL,
author CHAR(30) NOT NULL,
publisher CHAR(30),
topic CHAR(20),
comment CHAR(100),
price FLOAT
)
% mysql wbluhm < create_books.sql
For more examples, see some of the scripts from the samp_db database in
/users/science/wbluhm/mysql/create_*.sql
Column types
Some basic column types: INTEGER, FLOAT, CHAR, DATE, TIME, BLOB
Complete table of all column types on mysql.com
source :http://www.wbluhm.com/MySQLTut.html
0 komentar:
Post a Comment