知行合一

享受过程 漠视结果

导航

mysql简单命令示例

C:\mysql\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytest             |
| tjtz               |
| tjtz_148280117     |
+--------------------+
5 rows in set (0.00 sec)

mysql> create database mytest2;
Query OK, 1 row affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytest             |
| mytest2            |
| tjtz               |
| tjtz_148280117     |
+--------------------+
6 rows in set (0.00 sec)

mysql> use mytest2;
Database changed
mysql> create table testTable(
    -> id int(4) auto_increment not null primary key,
    -> name char(10not null,
    -> address char(50default 'jinan',
    -> year date);
Query OK, 0 rows affected (0.09 sec)

mysql> show tables;
+-------------------+
| Tables_in_mytest2 |
+-------------------+
| testtable         |
+-------------------+
1 row in set (0.05 sec)

mysql> insert into testtable values('','zhangsan','','2011-12-29');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from testtable;
+----+----------+---------+------------+
| id | name     | address | year       |
+----+----------+---------+------------+
|  1 | zhangsan |         | 2011-12-29 |
+----+----------+---------+------------+
1 row in set (0.00 sec)

mysql> update testtable set address='jiefang road';
Query OK, 1 row affected (0.06 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from testtable;
+----+----------+--------------+------------+
| id | name     | address      | year       |
+----+----------+--------------+------------+
|  1 | zhangsan | jiefang road | 2011-12-29 |
+----+----------+--------------+------------+
1 row in set (0.00 sec)

mysql> insert into testtable values('','lisi',null,'2012-1-3');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from testtable;
+----+----------+--------------+------------+
| id | name     | address      | year       |
+----+----------+--------------+------------+
|  1 | zhangsan | jiefang road | 2011-12-29 |
|  2 | lisi     | NULL         | 2012-01-03 |
+----+----------+--------------+------------+
2 rows in set (0.00 sec)

mysql>

posted on 2012-01-06 17:41  项羽  阅读(286)  评论(0)    收藏  举报