好的,所以我看到这是错误的方法:
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>
has 应该填充触发器吗?
好的,作为 root 我做了一个触发器:
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>
但是,这只是虚拟数据。如何使该触发器实际创建哈希?