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