你可以参考下面事例 mysql> create table animals(id int not null auto_increment primary key, name char(32) not null);Query OK, 0 rows affected (0.08 sec)mysql> insert into animals(name) values ('dog'), ('cat');Query OK, 2 rows affected (0.00 sec)Records: 2 Duplicates...
谁能给个mysql创建序列sequence 和触发器的例子
你可以参考下面事例
mysql> create table animals(id int not null auto_increment primary key, name char(32) not null);Query OK, 0 rows affected (0.08 sec)mysql> insert into animals(name) values ('dog'), ('cat');Query OK, 2 rows affected (0.00 sec)Records: 2 Duplicates: 0 Warnings: 0mysql> select * from animals;+----+------+| id | name |+----+------+| 1 | dog || 2 | cat |+----+------+2 rows in set (0.00 sec)mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account -> FOR EACH ROW SET @sum = @sum + NEW.amount;mysql> SET @sum = 0;mysql> INSERT INTO account VALUES(137,14.98),(141,1937.50),(97,-100.00);mysql> SELECT @sum AS 'Total amount inserted';+-----------------------+| Total amount inserted |+-----------------------+| 1852.48 |+-----------------------+mysql> DROP TRIGGER account.ins_sum;2015-06-02