|
|
|
|
|
|
   
  Friends Login:  
Saturday, 19 May 2012
 
 
My Blog



Replace Into - MySql Query
August 2, 2008
I like using this syntax in MySql coz it have a simple syntax and so efficient when I want to insert a record but if it already exist, it'll update the data... 
but it not too recommended, coz from the statement below.. REPLACE INTO will slower the performer...

Mechanism ::

   1. Try to insert the new row into the table
   2. While the insertion fails because a duplicate-key error occurs for a primary key or unique index:
         1. Delete from the table the conflicting row that has the duplicate key value
         2. Try again to insert the new row into the table

Syntac ::
REPLACE INTO F SELECT * FROM T;
REPLACE INTO F(a, b, c) SELECT a, b, c FROM T;
Summary:
REPLACE INTO becomes more efficient from DELETE FROM… INSERT INTO… but  much slower performer than an UPDATE statement. Better use “INSERT … ON DUPLICATE KEY UPDATE…” as an alternative if you’re looking at a single unique column table (Primary Key).

source : http://blog.sherlock-group.com
Category :  Programming   Comment : 0 Comment
Triggers in MySql
July 16, 2007
Today I learned bout Triggers in MySql,
Triggers are programmable events that react to queries and reside directly on the database server. Triggers can be executed before or after INSERT, UPDATE or DELETE statements.

with triggers, we can know what data has been insert, update or delete.
actually it's easy to create, this is the example:

DELIMITER |

CREATE TRIGGER newsCounter AFTER INSERT ON News
  FOR EACH ROW BEGIN
      INSERT INTO NewsCount (newsItemCount) (SELECT count(*) FROM News);
  END;

|
DELIMITER ;


that example, is to get and insert the news count at NewsCount table when user insert at News table


and to get a triggers list at your database, you can run this:
SHOW TRIGGERS;


but u cannot create triggers from phpMyAdmin, it just can create from MySql Client like SQLyog (http://www.webyog.com/en/)

and sometimes you have to be a super user to create triggers at your database.

for more information bout triggers, u can visit this site:
http://dev.mysql.com/doc/mysql/en/triggers.html

it's quite fun, when u have to learn something new.. at your office
Category :  Programming   Comment : 2 Comment
Page : 1 

 

   
:: May '12 ::
 
S
M
T
W
T
F
S
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
 

:: My Blog List ::
   
 

:: Blog Category ::
 
» My Life
» Fashion
» Technology
» Foods & Drinks
» Health
» Love
» Music
» General Info
» Books
» Film
» Jokes
» Programming
» Christian Soul
» Games
 
 

:: Site Links ::
 
» Agung Setiadha
» Angel Sulistyo
» Anton Ongsono
» Anton Sukoco
» Arnita
» Aryo
» Azis
» BlackStyle
» Cokbun
» Darwin
» Elmo
» Fellys
» Inge
» Joandi
» Kado Imut
» Koleksi Unik
» Kue Bolu
» Lie Fung
» Lintaka
» Lobak
» Lucalry
» mare
» Oka
» Rasil
» Rosrita
» Stephanie Angela
» Tri Megah Chemical
 
 
 
From:
 
 


 

 
:: Book Reviews | Songs Collection | Film Reviews | Life Poems | Love Poems | Friendship Poems ::
Copyright ©  Lavinia ~ 2006 - 2012