mysql>
mysql> show tables;
+---------------------+
| Tables_in_nntp |
+---------------------+
| articles |
| newsgroups |
| newsgroups_articles |
+---------------------+
3 rows in set (0.00 sec)
mysql> describe newsgroups;
+-----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| newsgroup | longtext | NO | | NULL | |
+-----------+----------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> show create table newsgroups;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| newsgroups | CREATE TABLE `newsgroups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`newsgroup` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> ALTER TABLE newsgroups ADD UNIQUE (newsgroup);
ERROR 1170 (42000): BLOB/TEXT column 'newsgroup' used in key specification without a key length
mysql>
的已经应该用trigger填充?
好了,因为我的根做了一个触发像这样:
mysql>
mysql> show tables;
+---------------------+
| Tables_in_nntp |
+---------------------+
| articles |
| newsgroups |
| newsgroups_articles |
+---------------------+
3 rows in set (0.00 sec)
mysql>
mysql> delimiter |
mysql> CREATE TRIGGER make_hash BEFORE INSERT ON newsgroups
-> FOR EACH ROW BEGIN
-> INSERT INTO hash values ('0');
-> END;
-> |
Query OK, 0 rows affected (0.18 sec)
mysql>
然而,这只是虚拟数据。我怎么能让这个触发器实际上创建哈希?
“TRIGGER命令剥夺了用户.. 。' - 你应该检查你的用户拥有什么特权,并且如果有必要的话,用不同的用户运行创建触发器。 – Vatev 2012-07-28 23:41:48
@Vatev我会以root身份尝试,但我不认为这是问题,用户java有'USAGE'。 – Thufir 2012-07-28 23:55:50