MyWeddingMall
Wedding Vendors
Get Listed Today >>>
Wedding Vendor   in Bothell WA

Bothell, Washington 98012

Send Message »
Rated 5/5 (1 Reviews)
Write a review


Make a connection! is currently accepting new clients. Send Message »

Contact Details

Location
19822 25th Drive SE
Bothell, WA 98012
United States
Map View Location of  Wedding Vendor

Get Directions »

Submitted on Wednesday, Jul 22, 2015

Yes, you can. Note

Yes, you can. Note in this example, cistteyt is the same as the table city (except city's id is auto_increment and a primary key, and doesn't contain the timestamp), so if you don't have that table in your test database you can create it using the same definition as cistteyt.mysql> insert into city (ID,name,CountryCode,District,Population) VALUES (1,'one','cc','district',12345);mysql> delimiter $$mysql> CREATE TRIGGER BUcity BEFORE UPDATE ON cityFOR EACH ROW BEGININSERT INTO cistteyt (ID,name,tstamp) VALUES (OLD.ID,OLD.name,NOW());INSERT INTO cistteyt (ID,name,tstamp) VALUES (NEW.ID,NEW.name,NOW());END;$$Query OK, 0 rows affected (0.03 sec)mysql> delimiter ;mysql> create table cistteyt (ID int not null,name char(35) not null default ,CountryCode char(3) not null default ,District char(20) not null default ,Population int not null default 0,tstamp timestamp);Query OK, 0 rows affected (0.19 sec)mysql> describe city;+ -+ -+ + + + -+| Field | Type | Null | Key | Default | Extra |+ -+ -+ + + + -+| ID | int(11) | NO | PRI | NULL | auto_increment || Name | char(35) | NO | | | || CountryCode | char(3) | NO | | | || District | char(20) | NO | | | || Population | int(11) | NO | | 0 | |+ -+ -+ + + + -+5 rows in set (0.01 sec)mysql> UPDATE city SET name='foo' WHERE name='one';Query OK, 1 row affected (0.02 sec)mysql> select * from cistteytGselect * from cistteytG*************************** 1. row *************************** ID: 1 name: oneCountryCode: District: Population: 0 tstamp: 2006-09-11 15:45:46*************************** 2. row *************************** ID: 1 name: fooCountryCode: District: Population: 0 tstamp: 2006-09-11 15:45:462 rows in set (0.00 sec)And now you have 2 rows with the old and new data. OLD and NEW are special table names inside the trigger, and they contain each row *modified* (not each row looked at).Also note that this is technically effective as a history table, but it means each update takes at least twice as long (1 insert + 1 update, PLUS the overhead of the trigger itself), and is not a proper audit, as the DBA has control over the database and can change the data.

  • Recommended:

    Yes
  • Overall:

    5 out of 5
  • Service:

    4 out of 5
  • Responsiveness:

    2 out of 5
  • Expertise:

    3 out of 5
  • Results:

    1 out of 5
  • Communication:

    3 out of 5

Have you worked with ?

Write A Review Now »