D:\Tools\MySQL4\bin>mysql -uroot -p Enter password: ******* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 30 Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use ok Database changedmysql> create table t(qty int,price int); Query OK, 0 rows affected (0.09 sec)mysql> insert into t values(3,50); Query OK, 1 row affected (0.02 sec)mysql> create view v as select qty,price,qty*price as value from t; Query OK, 0 rows affected (0.03 sec)mysql> select * from v; +------+-------+-------+ | qty | price | value | +------+-------+-------+ | 3 | 50 | 150 | +------+-------+-------+ 1 row in set (0.02 sec)mysql>完全没有问题的哦
select qty,price,(qty*price) as value from t;
这样呢?
再在dos中照着输一遍
没有主键好像不可以建表,
字段需要长度吧
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use ok
Database changedmysql> create table t(qty int,price int);
Query OK, 0 rows affected (0.09 sec)mysql> insert into t values(3,50);
Query OK, 1 row affected (0.02 sec)mysql> create view v as select qty,price,qty*price as value from t;
Query OK, 0 rows affected (0.03 sec)mysql> select * from v;
+------+-------+-------+
| qty | price | value |
+------+-------+-------+
| 3 | 50 | 150 |
+------+-------+-------+
1 row in set (0.02 sec)mysql>完全没有问题的哦