#drizzle sql语法参考:http://docs.drizzle.org/#sql-language
现在,你就可以向服务器发出SQL命令了,就像用MySQL客户端那样。
drizzle> SELECT VERSION();
+--------------+
| VERSION() |
+--------------+
| 2009.06.1063 |
+--------------+
1 row in set (0 sec)
我们先创建一个数据库并添加一张表:
drizzle> CREATE DATABASE test;
Query OK, 1 row affected (0 sec)
drizzle> USE test;
Database changed
drizzle> CREATE TABLE items (
-> ItemID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> ItemDesc VARCHAR(255) NOT NULL,
-> ItemQty INT NOT NULL
-> );
Query OK, 0 rows affected (0.01 sec)
据Drizzle FAQ所述,Drizzle支持TEXT, BLOB, VARCHAR, VARBINARY, TIMESTAMP, DATETIME, DATE, TIME, ENUM, INT, DOUBLE以及DECIMAL 这些字段类型。通过MySQL,你可能已经对这其中的许多了如指掌了
下面通过向表中填充一些记录来继续我们的示例演示:
drizzle> INSERT INTO items (ItemDesc, ItemQty) VALUES ('Bacon', 4);
Query OK, 1 row affected (0 sec)
drizzle> INSERT INTO items (ItemDesc, ItemQty) VALUES ('Eggs', 3);
Query OK, 1 row affected (0 sec)
drizzle> INSERT INTO items (ItemDesc, ItemQty) VALUES ('Milk', 1);
Query OK, 1 row affected (0 sec)
drizzle> INSERT INTO items (ItemDesc, ItemQty) VALUES ('Apples', 6);
Query OK, 1 row affected (0.01 sec)
简单运行一个SELECT语句看看是否一切正常:
drizzle> SELECT * FROM items;
+--------+----------+---------+
| ItemID | ItemDesc | ItemQty |
+--------+----------+---------+
| 1 | Bacon | 4 |
| 2 | Eggs | 3 |
| 3 | Milk | 1 |
| 4 | Apples | 6 |
+--------+----------+---------+
4 rows in set (0 sec)