mysqlÖд¥·¢Æ÷µÄÓ¦ÓÃ
Õ⼸ÌìѧϰÁË´¥·¢Æ÷µÄÓ÷¨£¬¾õµÃ´¥·¢Æ÷ºÜºÃÓð¡¡£
´¥·¢Æ÷µÄ»ù±¾Óï·¨£º
CREATE TRIGGER <´¥·¢Æ÷Ãû><--
{BEFORE | AFTER}
{ INSERT | UPDATE | DELETE }
ON <±íÃû³Æ>
FOR EACH ROW
<´¥·¢Æ÷SQLÓï¾ä>
¹æÔò£º
1.´¥·¢Æ÷±ØÐëÓÐÃû×Ö£¬×î¶à64¸ö×Ö·û£¬¿ÉÄܺóÃæ»á¸½Óзָô·û.ËüºÍMySQLÖÐÆäËû¶ÔÏóµÄÃüÃû·½Ê½»ù±¾ÏàÏó
2.ÎÒÃDz»ÄܸøͬһÕűíµÄͬһ¸öʼþ°²ÅÅÁ½¸ö´¥·¢Æ÷
3.FOR EACH ROW×Ó¾ä֪ͨ´¥·¢Æ÷ÿ¸ôÒ»ÐÐÖ´ÐÐÒ»´Î¶¯×÷£¬¶ø²»ÊǶÔÕû¸ö±íÖ´ÐÐÒ»´Î¡£
4.Äã±ØÐëÓµÓÐÏ൱´óµÄȨÏÞ²ÅÄÜ´´½¨´¥·¢Æ÷£¨CREATE TRIGGER£©¡£
5.´¥·¢Æ÷°üº¬ËùÒª´¥·¢µÄSQLÓï¾ä£ºÕâÀïµÄÓï¾ä¿ÉÒÔÊÇÈκκϷ¨µÄÓï¾ä£¬°üÀ¨¸´ºÏÓï¾ä£¬µ«ÊÇÕâÀïµÄÓï¾äÊܵÄÏÞÖƺͺ¯ÊýµÄÒ»Ñù:
ALTER 'CACHE INDEX' CALL COMMIT CREATE DELETE
DROP 'FLUSH PRIVILEGES' GRANT INSERT KILL
LOCK OPTIMIZE REPAIR REPLACE REVOKE
ROLLBACK SAVEPOINT 'SELECT from table'
'SET system variable' 'SET TRANSACTION'
SHOW 'START TRANSACTION' TRUNCATE UPDATE
6.¿ÉÒÔʹÓÃNEWÓëOLD¹Ø¼ü×ÖÀ´·ÃÎʸüÐÂÇ°ºóµÄÊý¾Ý
ÀýÈ磺
create trigger t3
after
delete on article for each row
insert into xy_user(name,email,hobby)values('admin','admin@163.com','zuqiu');
Ïà¹ØÎĵµ£º
Ò».°²×°
rpm·½Ê½
rpm -ivf MySQL*
tar·½Ê½
tar xzvf mysql-x.xx.tar.gz
cd mysqlp-x.xx Éú³Émakefile
./congigure
make ±àÒë
make install
mysql_install_db
¶þ.Æô¶¯¡¢¹Ø±Õ
ser ......
cmdÏÂÇл»µ½ mysql °²×°Ä¿Â¼
Àý
d:/mysql/bin (Èç¹ûÓÃWAMP°²×°ÔòÊÇD:\wamp\bin\mysql\mysql5.1.30\bin)
Ç°Ì᣺mysqlÓû§rootÃÜÂëΪ¿Õ.
ÊäÈë mysql -u root mysql
mysql> ״̬ÏÂÊäÈë update user set password=password('ÐÂÃÜÂë') where user='root';
»ØÏÔ
Query OK, 0 rows ......
ÏÈÏÂÔØÒ»¸ömysqlµÄÇý¶¯Æ÷£º£¨ÎÒϵÄÊÇmysql-connector-java-3.1.11-bin.jar£©
½«Ëü·Åµ½java\libĿ¼ÏÂ
ÔÚ»·¾³±äÁ¿µÄCLASSPATHÀïÌí¼Ó¸ÃÀࣨ%JAV_HOMG%\lib\mysql-connector-java-3.1.11-bin.jar)
³ö²âÊԸöδúÂë¼´¿É£º
import java.net.URL;
import java.sql.*;
public class sqlTest {
public static void mai ......
1.½¨±í¹ý³ÌÈçÏÂ
create database test default character set utf8 collate utf8_general_ci
use test;
create table devicedata
(
ID int auto_increment PRIMARY key ,
TimeStamp datetime,
Device_Name varchar(100),
Tag_Name varchar(100),
Value varchar(50)
)
2 ......
1£ºMysql ÃüÁî²»¿ÉÒÔÖ´ÐÐ
ÔÒò £ººÇºÇ ±ÈÈç show databases µÄÃüÁî £¬Ö´ÐÐÍêÖ®ºó ɶҲûÓÐ £¬×Ðϸ ÕÒÁËÔÒò £¬Oh my god ÉÙÁË ·ÖºÅ¡£
Ӧд³É£ºshow databases;
2£ºÃüÁîÐÐÖÐÎÄÂÒÂëÎÊÌâ
ÏÖÏó£ºmysqlµÄĬÈϱàÂëÉèÖÃΪutf-8£¬Ò³ÃæÒÔutf-8µÄ±àÂ뷽ʽдÈëµ½Êý¾Ý¿â¡£Óù¤¾ß²é¿´Ò»ÇÐÕý³££¬µ«´ÓmysqlµÄÃüÁîÐжÁÊý¾Ý³öÀ´× ......