'분류 전체보기'에 해당되는 글 178건

  1. 2009.02.19 MySQL 5.0에서 Trigger 사용하기
  2. 2009.02.13 [헬스]스트레칭 사진 30개
  3. 2009.02.13 [헬스]북근빨리만들기
  4. 2009.02.11 DOS모드의 파일을 UNIX 모드로 일괄 변경하기
  5. 2009.02.11 PC에 남겨진 개인정보 제거하기
  6. 2009.02.11 Internet Explorer & Fire Fox 속도향상
  7. 2009.02.11 [오라클] LOCK 문제를 일으키는 SQL 명령 찾기
  8. 2009.02.11 HTTP 패킷 모니티링 툴
  9. 2009.02.11 MSN 메신저를 홈페이지에 달기
  10. 2009.02.11 원도우 오류 보고 사용하지 않기
2009. 2. 19. 13:32

MySQL 5.0에서 Trigger 사용하기

MySQL 5.0에서 Trigger 사용하기. ^^*


※ Trigger 생성하기

mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));
Query OK, 0 rows affected (0.03 sec)

mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account
    -> FOR EACH ROW SET @sum = @sum + NEW.amount;
Query OK, 0 rows affected (0.06 sec)


[참고] 트리거의 데이터는 DB 데이터가 위치하는 곳에 파일로 저장되며, 확장자명은 보통 TRG 이다.

해당 트리거의 Table 정보는 TRN 파일로 저장된다.

즉, 위와 같은 경우에는 ins_sum.TRG와 ins_sum.TRN 파일로 저장된다.

ins_sum.TRN 파일의 내용을 보면 다음과 같다.

TYPE=TRIGGERNAME
trigger_table=account <-- 테이블명


 

※ Trigger 시험하기

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               |
+-----------------------+


 

※ Trigger 확인하기

mysql> show triggers;
+----------------+--------+-------------------+-------------------+--------+---------+----------+----------------+
| Trigger        | Event  | Table             | Statement         | Timing | Created | sql_mode | Definer        |
+----------------+--------+-------------------+-------------------+--------+---------+----------+----------------+
| Trigger Name   | INSERT | 관련 Table Name   | BEGIN  .....  END | BEFORE | NULL    |          | user@localhost |
+----------------+--------+-------------------+-------------------+--------+---------+----------+----------------+


※ Trigger 삭제하기

mysql> DROP TRIGGER test.ins_sum;


 


※ Trigger 생성하기의 또 다른 방법

mysql> delimiter //
mysql> CREATE TRIGGER upd_check BEFORE UPDATE ON account
    -> FOR EACH ROW
    -> BEGIN
    ->     IF NEW.amount < 0 THEN
    ->         SET NEW.amount = 0;
    ->     ELSEIF NEW.amount > 100 THEN
    ->         SET NEW.amount = 100;
    ->     END IF;
    -> END;//
mysql> delimiter ;



※ Error 보기

mysql> show errors;
Empty set (0.00 sec)



※ Trigger에서 사용하는 변수명은 반드시!! Table의 Column명과 다른 것을 사용(대소문자 구분없음)해야 한다. 만약 같은 변수명을 사용시 해당 값이 의도된 값이 아닌 다른(보통 Default값)으로 설정되게 된다.


MySQL의 show 명령에 대한 자세한 사항을 보고자 한다면 다음을 클릭.

 http://blog.naver.com/iamfreeman/50036208287


//------------------------------------------------------------------------//

참고 사이트 : http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html

17.3.1. Trigger Syntax

To create a trigger or drop a trigger, use the CREATE TRIGGER or DROP TRIGGER statement. The syntax for these statements is described in Section 12.1.10, “CREATE TRIGGER Syntax”, and Section 12.1.17, “DROP TRIGGER Syntax”.

Here is a simple example that associates a trigger with a table for INSERT statements. The trigger acts as an accumulator, summing the values inserted into one of the columns of the table.

mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));
Query OK, 0 rows affected (0.03 sec)

mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account
    -> FOR EACH ROW SET @sum = @sum + NEW.amount;
Query OK, 0 rows affected (0.06 sec)

The CREATE TRIGGER statement creates a trigger named ins_sum that is associated with the account table. It also includes clauses that specify the trigger activation time, the triggering event, and what to do with the trigger activates:

  • The keyword BEFORE indicates the trigger action time. In this case, the trigger should activate before each row inserted into the table. The other allowable keyword here is AFTER.
  • The keyword INSERT indicates the event that activates the trigger. In the example, INSERT statements cause trigger activation. You can also create triggers for DELETE and UPDATE statements.
  • The statement following FOR EACH ROW defines the statement to execute each time the trigger activates, which occurs once for each row affected by the triggering statement In the example, the triggered statement is a simple SET that accumulates the values inserted into the amount column. The statement refers to the column as NEW.amount which means “the value of the amount column to be inserted into the new row.

To use the trigger, set the accumulator variable to zero, execute an INSERT statement, and then see what value the variable has afterward:

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               |
+-----------------------+

In this case, the value of @sum after the INSERT statement has executed is 14.98 + 1937.50 - 100, or 1852.48.

To destroy the trigger, use a DROP TRIGGER statement. You must specify the schema name if the trigger is not in the default schema:

mysql> DROP TRIGGER test.ins_sum;

Triggers for a table are also dropped if you drop the table.

Trigger names exist in the schema namespace, meaning that all triggers must have unique names within a schema. Triggers in different schemas can have the same name.

In addition to the requirement that trigger names be unique for a schema, there are other limitations on the types of triggers you can create. In particular, you cannot have two triggers for a table that have the same activation time and activation event. For example, you cannot define two BEFORE INSERT triggers or two AFTER UPDATE triggers for a table. This should rarely be a significant limitation, because it is possible to define a trigger that executes multiple statements by using the BEGIN ... END compound statement construct after FOR EACH ROW. (An example appears later in this section.)

The OLD and NEW keywords enable you to access columns in the rows affected by a trigger. (OLD and NEW are not case sensitive.) In an INSERT trigger, only NEW.col_name can be used; there is no old row. In a DELETE trigger, only OLD.col_name can be used; there is no new row. In an UPDATE trigger, you can use OLD.col_name to refer to the columns of a row before it is updated and NEW.col_name to refer to the columns of the row after it is updated.

A column named with OLD is read only. You can refer to it (if you have the SELECT privilege), but not modify it. A column named with NEW can be referred to if you have the SELECT privilege for it. In a BEFORE trigger, you can also change its value with SET NEW.col_name = value if you have the UPDATE privilege for it. This means you can use a trigger to modify the values to be inserted into a new row or that are used to update a row.

In a BEFORE trigger, the NEW value for an AUTO_INCREMENT column is 0, not the automatically generated sequence number that will be generated when the new record actually is inserted.

OLD and NEW are MySQL extensions to triggers.

By using the BEGIN ... END construct, you can define a trigger that executes multiple statements. Within the BEGIN block, you also can use other syntax that is allowed within stored routines such as conditionals and loops. However, just as for stored routines, if you use the mysql program to define a trigger that executes multiple statements, it is necessary to redefine the mysql statement delimiter so that you can use the ; statement delimiter within the trigger definition. The following example illustrates these points. It defines an UPDATE trigger that checks the new value to be used for updating each row, and modifies the value to be within the range from 0 to 100. This must be a BEFORE trigger because the value needs to be checked before it is used to update the row:

mysql> delimiter //
mysql> CREATE TRIGGER upd_check BEFORE UPDATE ON account
    -> FOR EACH ROW
    -> BEGIN
    ->     IF NEW.amount < 0 THEN
    ->         SET NEW.amount = 0;
    ->     ELSEIF NEW.amount > 100 THEN
    ->         SET NEW.amount = 100;
    ->     END IF;
    -> END;//
mysql> delimiter ;

It can be easier to define a stored procedure separately and then invoke it from the trigger using a simple CALL statement. This is also advantageous if you want to invoke the same routine from within several triggers.

There are some limitations on what can appear in statements that a trigger executes when activated:

  • The trigger cannot use the CALL statement to invoke stored procedures that return data to the client or that use dynamic SQL. (Stored procedures are allowed to return data to the trigger through OUT or INOUT parameters.)
  • The trigger cannot use statements that explicitly or implicitly begin or end a transaction such as START TRANSACTION, COMMIT, or ROLLBACK.
  • Prior to MySQL 5.0.10, triggers cannot contain direct references to tables by name.

MySQL handles errors during trigger execution as follows:

  • If a BEFORE trigger fails, the operation on the corresponding row is not performed.
  • A BEFORE trigger is activated by the attempt to insert or modify the row, regardless of whether the attempt subsequently succeeds.
  • An AFTER trigger is executed only if the BEFORE trigger (if any) and the row operation both execute successfully.
  • An error during either a BEFORE or AFTER trigger results in failure of the entire statement that caused trigger invocation.
  • For transactional tables, failure of a statement should cause rollback of all changes performed by the statement. Failure of a trigger causes the statement to fail, so trigger failure also causes rollback. For non-transactional tables, such rollback cannot be done, so although the statement fails, any changes performed prior to the point of the error remain in effect.


User Comments

Add your own comment.

2009. 2. 13. 17:50

[헬스]스트레칭 사진 30개

스트레칭 사진 30개
 

- 정확한 자세로 10-20초 정도 머물러야 합니다.

- 동작중의 호흡을 자연스럽게 해야 합니다.

- 이완되는 근육에 집중하여 실시하면 더 큰 효과를 볼 수 있습니다.

- 과도하게 스트레칭하거나 반동을 이용한 동작을 하면 오히려 상해의 원인이 됩니다.

사용자 삽입 이미지

2009. 2. 13. 17:45

[헬스]북근빨리만들기

사용자 삽입 이미지
2009. 2. 11. 16:39

DOS모드의 파일을 UNIX 모드로 일괄 변경하기

 

[root@ihelpers cv]# cat dos2unix

#/bin/sh

find ../html -name "*.php3" -print -exec perl -p -i -e "s/^M//g" {} \;
find ../html -name "*.php" -print -exec perl -p -i -e "s/^M//g" {} \;
find ../html -name "*.html" -print -exec perl -p -i -e "s/^M//g" {} \;
find ../html -name "*.htm" -print -exec perl -p -i -e "s/^M//g" {} \;

^M 문자열은 CTRL+V+ENTER 로 입력한다.

[root@ihelpers cv]# ./dos2unix

...

출처 : http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=7&KEY=&SC=S&&CC=&PAGE=1&IDX=584

2009. 2. 11. 16:27

PC에 남겨진 개인정보 제거하기

익스플로러를 이용해 돌아다닌 www 사이트의 목록과 그 웹 페이지의 각종 콘텐츠는 고스란히 하드디스크에 저장된다. 이렇게 저장된 파일을 통해서 사용자가 어떤 사이트를 언제 연결하고 거기서 무엇을 봤는지를 파악할 수 있다. 아침부터 저녁까지 누가 나를 미행한다면 그 마음이 어떨까? 익스플로러로 돌아다닌 인터넷 흔적을 보는 것은 현실 세계에서의 미행이나 다를 바 없다. 이러한 정보를 삭제하는 방법을 알아본다.

인터넷 사용 내역 삭제하기

익스플로러의 즐겨찾기 삭제하기
① C드라이브에서 ‘Documents and Settings’에는 윈도우 사용자별로 익스플로러와 아웃룩 익스프레스, 그리고 각종 응용 프로그램의 사용자 환경설정 등이 저장되는 폴더들이 위치해 있다. 이 폴더에는 윈도우 사용자 계정의 이름별로 폴더가 제공된다. 이 폴더에서 내가 사용하는 사용자 이름을 더블 클릭한다.
② ‘즐겨찾기’에는 익스플로러에서 즐겨찾기로 등록된 사이트 목록이 기록되어 있다. ‘My Documents’는 내문서다. 우선 즐겨찾기를 더블 클릭해본다.
③ 익스플로러의 즐겨찾기 목록이 폴더와 사이트 URL로 구분되어 저장되어 있다. 이 모든 파일을 삭제하자. 삭제할 때는 휴지통에 저장되지 않고 바로 삭제되도록 ‘Shift’를 누른 상태에서 ‘예’를 클릭한다.


익스플로러의 쿠키 기록 삭제하기
쿠기(Cookies) 폴더에는 인터넷 서핑을 하며 기록해둔 특정 인터넷 사이트의 사용자 정보(사용자 아이디, 암호 등)가 저장되어 있다. 이 폴더에 저장된 모든 파일도 삭제한다.


익스플로러로 연결한 사이트 정보 삭제하기
① Local Settings을 더블 클릭하면 ‘History’와 ‘Temporary Internet Files’이 나타난다. ‘Temporary Internet Files’에는 익스플로러로 연결해본 인터넷 사이트의 HTML 페이지와 각종 이미지, 플래시 파일이 저장되어 있다. 이 폴더에 저장된 파일을 모두 삭제한다.
② 그리고 ‘History’를 더블 클릭한다. 익스플로러를 이용해 연결했던 사이트 목록이 날짜별로 정리되어 있다. 이 목록도 모두 삭제한다.


인스턴트 메신저에 기록된 정보 삭제하기
① MSN 메신저에도 많은 정보가 기록되어 있다. 우선 사용자 이름과 암호를 통해서 MSN 메신저로 로그인하는데 이 아이디와 암호가 MSN 메신저에 저장되어 있다. 이것을 삭제하려면 ‘제어판→사용자 계정’을 실행한다.
② 사용자 계정에서 ‘내 네트워크 암호 관리’를 실행하고 ‘Passport’라고 씌어진 항목을 모두 제거한다. 이곳에 기록된 아이디와 암호가 MSN 메신저에 로그인할 때 사용된다.
③ 그 외에 MSN 메신저에는 대화 내용을 저장하는 기능이 제공된다. 이 기능이 활성화되어 있으면 메신저로 대화한 내용이 파일로 저장된다. 이 파일이 저장된 폴더의 위치를 찾아서 해당 파일을 모두 삭제해준다.
④ MSN 메신저로 다운로드 받은 전송 파일도 모두 제거해준다. 이 파일이 저장된 위치를 찾아서 말끔하게 삭제해준다.


개인 데이터 삭제하기
컴퓨터에 저장된 각종 개인 파일을 쉽게 없애려면 계정을 삭제하면 된다. 사용자 계정을 삭제하면 자동으로 해당 사용자가 남긴 익스플로러의 즐겨찾기, 열어본 페이지 목록과 전자우편 메시지는 물론 내 문서의 데이터까지 한꺼번에 모두 삭제할 수 있다.
만일, 이 같은 방법으로 일일이 삭제하는 것이 번거롭다면 계정을 통째로 삭제하여 개인 정보를 쉽게 삭제할 수 있다. 단 이렇게 계정을 삭제한 후에는 혹시나 남아있을 지 모를 하드디스크의 각종 개인 파일을 찾아서 추가로 삭제해줘야 한다.


사용자 계정 정보 삭제하기
① 사실 앞서 살펴본 것처럼 일일이 사용자 흔적을 없애는 것보다 사용자 계정을 통째로 없애버리면 한 번에 각종 개인 정보를 쉽게 없앨 수 있다. 윈도우XP를 사용하고 있다면 우선 새로운 계정을 하나 생성한 후에 기존에 내가 사용하던 계정은 통째로 삭제해버린다. 이렇게 하면 내 개인정보를 쉽고 간단하게 초기화할 수 있다.
② 삭제할 계정을 클릭한다. 기존에 사용하던 모든 계정을 이러한 방법으로 삭제해주고 새 계정을 하나 만들어두는 것이 가장 좋다.
③ '계정 삭제'를 클릭한다.
④ 계정을 삭제함과 동시에 그 계정 사용자가 사용하던 바탕화면, 내문서, 즐겨찾기, 전자메일 메시지와 각종 설정을 통째로 삭제하려면 이때 파일 유지가 아닌 '파일 삭제'를 클릭한다.
⑤ 모든 파일이 삭제되었다. 이제 '계정 삭제'를 클릭한다.
⑥ 계정이 삭제되었다면 이러한 방법으로 다른 사용자 계정도 모두 삭제한다. 그리고 새로운 계정을 하나 생성해준다.
⑦ 사용자 계정을 삭제한 후에는 내가 개인적으로 설치했던 각종 프로그램도 삭제한다. 특히 보안 유틸리티와 회사에서 설치해주지 않은 모든 프로그램은 삭제한다. 프로그램을 삭제할 때는 '제어판→프로그램 추가/제거'를 이용한다.

각종 개인 자료들 삭제하기
① 대개의 파일들은 내문서라는 폴더에 저장돼 있다. 내문서에 저장된 파일 중에서 회사 업무를 위한 문서 외에 개인적으로 다운로드 받거나 저장한 음악, 영화, 이미지 파일은 모두 삭제한다. 내문서 외에 바탕화면이나 C, D 드라이브 등에 저장된 개인파일들은 빠짐없이 찾아서 삭제해주어야 한다.
② 일부 파일은 내문서가 아닌 다른 폴더나 드라이브에 저장되어 있을 수 있다. 이러한 경우에는 윈도우의 '시작→검색' 기능을 이용해서 확장자가 MP3, JPG, AVI 등으로 된 파일을 찾아서 삭제한다.
③ 최근에는 디지털 카메라 보급이 늘어 카메라로 촬영한 이미지 파일이 컴퓨터에 저장된 경우가 많다. 이들 파일도 잊지 말고 모두 삭제해야 한다.
④ 사실 이렇게 파일을 삭제하고 휴지통을 비우더라도 삭제된 파일을 복구해주는 유틸리티를 이용하면 금세 파일 복구가 가능하다. 보안상 외부에 절대 유출돼서는 안되는 파일인 경우에는 파일을 복구할 수 없도록 완벽하게 제거해주는 BCWipe와 같은 파일 삭제 유틸리티를 이용해야 한다. 이러한 유틸리티를 이용하면 완벽하게 파일을 삭제한다.


각종 응용 프로그램의 사용자 정보
각종 응용 프로그램에서 사용하는 사용자 정보도 삭제해준다. 이러한 정보는 'C:\Documents and Settings\사용자 계정\Application Data'에 기록돼 있다. 이곳에 기록된 모든 파일은 삭제한다. 또 ‘C:\Documents and Settings\사용자 계정\Local Settings\Application Data'에서 'Identities', 'Microsoft' 등의 폴더도 삭제한다. 'Identities' 폴더에는 전자우편 메시지가 기록되어 있으며, 'Microsoft'에는 아웃룩의 메시지와 주소록 등이 저장되어 있기 때문이다.

공인인증서 삭제하기
사용자 정보를 삭제할 때 반드시 잊지 말아야 할 것이 공인인증서다. 인증서도 삭제를 해줘야 한다. 인증서를 삭제하려면 은행 홈페이지를 방문해서 '인증서 관리' 메뉴의 '인증서 삭제'를 이용한다. 혹은 공인인증서 홈페이지인 'www.signgate.com'에서 삭제할 수도 있다.


* 이 글은 한국정보문화진흥원(KADO)의 웹진인 따뜻한 디지털 세상 인포메이션 코너에 실린 글을 전재한 것입니다. 이 글의 필자 김지현 님은 테크라이터, 테크니컬 애널리스트, 강사, IT 사업의 기획자로서 활동하고 있는 칼럼니스트로 필자 홈페이지도 운영하고 있으니 원고에 대한 문의는 필자의 메일이나 홈페이지(www.oojoo.co.kr)로 보내시면 됩니다.

출처 : http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=7&KEY=&SC=S&&CC=&PAGE=2&IDX=508
2009. 2. 11. 16:24

Internet Explorer & Fire Fox 속도향상

 

가. Internet Explorer

Internet Explorer의 경우 한 웹서버에 대하여 기본적인 동시 접속 설정값이 2~4 이기에, 이미지가 많은 웹사이트의 경우는 페이지 전체의 로딩속도가 늦습니다.

아래와 같이 설정값을 변경을 통하여 빠른 페이지를 조회하여 보실 수 있습니다.

1. 설정값 변경

  • 시작 > 실행 > "regedit" 실행
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
  • MaxConnectionsPerServer, MaxConnectionsPer1_0Server 값을 변경 또는 생성

    해당 설정값이 없을 경우는  DWORD 값으로 생성해 주셔야 합니다.

    MaxConnectionsPerServer - HTTP 1.1 서버의 동시 요청수
    MaxConnectionsPer1_0Server - HTTP 1.0 서버의 동시 요청수

    일반적으로 25 ~ 50 정도가 적당한 것 같습니다.

2. Reg 파일 다운로드

나. Fire Fox

  1. URL 바에 "about:config"  을 입력한다.
  2. "network.http.pipelining" to "true" 로 설정한다.
  3. "network.http.proxy.pipelining" to "true" 로 설정한다.
  4. "network.http.pipelining.maxrequests" 을 30~50 으로 설정한다.
  5. 마우스 오른쪽 키를 이용하여 "새로만들기 > 정수" 에서 이름 : "nglayout.initialpaint.delay", 값 : 0 으로 설정한다.


다. 참고


출처 : http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=7&KEY=&SC=S&&CC=&PAGE=2&IDX=520

2009. 2. 11. 16:16

[오라클] LOCK 문제를 일으키는 SQL 명령 찾기

LOCK 문제를 일으키는 SQL 명령 찾기
----------------------------------
* 다음 Query는 Lock과 관련된 트랜잭션을 출력해준다.

column username format a10
column sid format 999
column lock_type format a15
column MODE_HELD format a11
column MODE_REQUESTED format a10
column LOCK_ID1 format a8
column LOCK_ID2 format a8
select a.sid,
decode(a.type,
'MR', 'Media Recovery',
'RT', 'Redo Thread',
'UN', 'User Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL User Lock',
'DX', 'Distributed Xaction',
'CF', 'Control File',
'IS', 'Instance State',
'FS', 'File Set',
'IR', 'Instance Recovery',
'ST', 'Disk Space Transaction',
'IR', 'Instance Recovery',
'ST', 'Disk Space Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalidation',
'LS', 'Log Start or Switch',
'RW', 'Row Wait',
'SQ', 'Sequence Number',
'TE', 'Extend Table',
'TT', 'Temp Table',
a.type) lock_type,
decode(a.lmode,
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive', /* X */
to_char(a.lmode)) mode_held,
decode(a.request,
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive', /* X */
to_char(a.request)) mode_requested,
to_char(a.id1) lock_id1, to_char(a.id2) lock_id2
from v$lock a
where (id1,id2) in
(select b.id1, b.id2 from v$lock b where b.id1=a.id1 and
b.id2=a.id2 and b.request>0)
/


( 위의 Query를 실행시키면 다음과 같은 내용이 출력된다. )

SID LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2
--- --------------- ---------- ---------- -------- --------
5 Transaction Exclusive None 262172 90
6 Transaction None Exclusive 262172 90
9 Transaction None Exclusive 262172 90

SID 6과 9는 SID 5가 걸고 있는 Lock이 풀리기를 기다리고 있음을 알 수 있다.

* 다음 Query는 Lock과 관련된 테이블을 출력해 준다.

column username format a10
column lockwait format a10
column sql_text format a80
column object_owner format a14
column object format a15
select b.username username, c.sid sid, c.owner object_owner,
c.object object, b.lockwait, a.sql_text SQL
from v$sqltext a, v$session b, v$access c
where a.address=b.sql_address and
a.hash_value=b.sql_hash_value and
b.sid = c.sid and c.owner != 'SYS';
/

( 위의 Query를 실행하면 다음과 같은 결과가 출력된다.

USERNAME SID OBJECT_OWNER OBJECT LOCKWAIT
--------------- --- ------------- -------------- ----------
SQL
---------------------------------------------------------------
LTO2 6 LTO EMP C3D320F4
update lto.emp set empno =25 where empno=7788
LTO3 9 LTO EMP C3D320C8
delete from lto.emp where empno=7788
LTO 5 LTO DEPT
insert into lto.dept values (60,'PROGRAMMER','LOS ANGELOS')

여기서는 USERNAME에 나와있는 유저가 OBJECT에 나와있는 테이블을 수정하려고
함을 나타낸다. LT02,LT03는 LT0가 Commit,Rollback 하기를 기다리고 있음을 알
수 있다. 하지만 여기에는 가장 최근의 DML 명령 하나만 나와있기 때문에 여기
나온 명령이 반드시 Lock을 걸고 있는 명령이라고 단정지을 수는 없다.

관련된 프로세스
---------------
* 다음 Query를 실행해 보면 프로세스와 관련된 정보를 얻을 수 있다.

column "ORACLE USER" format a11
column SERIAL# format 9999999
column "OS USER" format a8
select substr(s.username,1,11) "ORACLE USER", p.pid "PROCESS ID",
s.sid "SESSION ID", s.serial#, osuser "OS USER",
p.spid "PROC SPID",s.process "SESS SPID", s.lockwait "LOCK WAIT"
from v$process p, v$session s, v$access a
where a.sid=s.sid and
p.addr=s.paddr and
s.username != 'SYS'
/

* 위의 Query를 실행하면 다음과 같은 결과가 출력된다.

ORACLE PROCESS SESSION SERIAL# OS USER PROC SESS LOCKWT 
USER ID ID SPID SPID 
------ ------- ------- ------- ------- ---- ---- ------
LTO 19 5 31 usupport 17312 17309
LTO2 25 6 43 usupport 17313 17310 C3D320F4
LTO3 26 9 1 usupport 17314 17311 C3D320D8

이 때는 다음과 같이 조치한다.

1. LTO에게 Commit,Rollback 할 것을 요구한다.
2. SQLDBA>ALTER SYSTEM KILL SESSION '5,31';
3. %kill -9 17309 (유닉스상의 Shadown Process)
stop/id= (PROC SPID=SESS SPID on vms running single task)

여기서 SYS 유저는 제외시켰는데 필요하다면 Query의 Where 조건에서
s.username != 'SYS' 부분을 삭제하면 된다.

CATBLOCK.SQL & UTLLOCKT.SQL
---------------------------
$ORACLE_HOME/rdbms/admin 디렉토리에 있는 스크립트 가운데 catblock.sql과
utlockt.sql을 사용하여서 Lock 상황을 쉽게 파악할 수 있다. 이들은 다음과
같이 실행한다.

%cd $ORACLE_HOME/rdbms/admin
%sqldba lmode=y
SQLDBA>connect internal
SQLDBA>@catblock
SQLDBA>@catproc

결과는 다음 Query 문으로 알아 본다.

column waiting_session format a8
select lpad(' ',3*(level-1)) || waiting_session,
lock_type,
mode_requested,
mode_held,
lock_id1,
lock_id1,
lock_id2
from lock_holders
connect by prior waiting_session = holding_session
start with holding_session is null;

위의 Query에 의한 출력은 다음과 같다.

WAITING_ LOCK_TYPE MODE_REQUE MODE_HELD LOCK_ID1 LOCK_ID2
-------- ----------------- ---------- ---------- ---------- ----------
5 None
6 Transaction Exclusive Exclusive 262172 90
9 Transaction Exclusive Exclusive 262172 90

여기서 Session 6, Session 9가 Session 5를 기다리고 있음을 알 수 있다.

Lock & Hanging 문제를 추정하는 방법
-----------------------------------
프로그램 상에서 어느 부분이 Lock, Hanging 문제를 일으키는지 알아내기가
여의치 않을때 다음과 같은 방법을 사용해 보기 바란다.

1. init.ora의 sql_trace=ture로 세팅하면 연관된 SQL 명령이 출력될
것이다.
2. OS 상에서도 Process 상태를 점검하여 본다.
3. OS 상의 Debugging 기능을 사용하거나 만약 가능하다면 oradbx를 사용한다.
Platform 에 따라서 없을 수도 있다.
4. 여러가지 Monitoring 방법과 Locking/Blocking 스크립트를 이용한다.

PROCESS STACKS 확인
-------------------
때로는 Hanging Process나 리소스를 점유하고 있는 Process의 Process Stack을
점검해 보는 것이 문제 해결에 도움이 되는 경우가 있다.

1. OS Debugging 프로그램을 이용하여 Hangup 되기 전의 마지막 Call을 확인
한다.

ex)%truss -p 

2. oradbx(오라클 debugging 프로그램)은 Support,Development 시에만 사용
된다.

select substr(s.username,1,11) "ORACLE USER" ,
p.pid "PROCESS ID", s.sid "SESSION ID", s.serial#,
osuser "OS USER", p.spid "PROC SPID"
from v$session s, v$access a
where a.sid=s.sid and
p.addr=s.paddr and
s.username != 'SYS'
/

위의 Query를 실행하면 다음과 같은 결과가 출력된다.

ORACLE PROCESS SESSION SERIAL# OS USER PROC SESS LOCKWT 
USER ID ID SPID SPID 
------ ------- ------- ------- ------- ---- ---- ------ 
LTO 19 5 31 usupport 17312 17309 
LTO2 25 6 43 usupport 17313 17310 C3D320F4 
LTO3 26 9 1 usupport 17314 17311 C3D320D8

만약 oradbx가 없다면 다음과 같이 해서 만들어 준다.

%cd $ORACLE_HOME/rdbms/lib
%make -f oracle.mk oradbx

LTO Process가 무엇을 하고 있는지 알고 싶으면 Process Stack을 보면 알수
있다.

ps -ef | grep 17312
usupport 17312 17309 0 Sep 15 ? 0:00 oracleV713(DESCRIPTION=(LOCAL=YE
type 
debug 17312 (이 유저의 oracle shadow process)
dump stack
dump procstat

위에서 생성된 트레이스 화일(user_dump_dest 에 생성됨)을 이용하면 Hanging
문제를 해결하는데 큰 도움이 된다.

자주 발생하는 LOCK 문제들
-------------------------
1. Parent-Child 관계로 묶인 테이블에서 Child 테이블에 Index가 없는 상황
에서 Child 테이블을 수정하게 되면 Parent테이블에 TABLE LEVEL SHARE
LOCK이 걸리게 되어서 Parent 테이블에 대한 모든 Update가 금지된다.
2. 블럭의 PCTFREE가 매우 작다면 한 블럭에 여러개의 레코드가 들어 있기
때문에 한 블럭에 과도한 트랜잭션이 들어와서 블럭의 Transaction Layer가
Release 되기를 기다리게 되는 경우도 있다.

Ex)
create table test (a number) initrans 1 maxtrans 1;

SYSTEM: insert into test values (5); /* completed */
SCOTT: insert into SYSTEM.test values (10); /* Scott waits */

SID OWNER LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2
---- ----- ------------- ----------- ---------- -------- --------
7 System Transaction Exclusive None 196639 54
10 Scott Transaction None Share 196639 54



[출처] http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=6&KEY=&SC=S&&CC=&PAGE=1&IDX=408




2009. 2. 11. 16:12

HTTP 패킷 모니티링 툴

 

브라우저 툴바에 설치되어 손쉽게 HTTP 패킷을 모니터링 할수 있어 상당히 유용한듯

http://www.fiddlertool.com


출처 : http://cafe.naver.com/ArticleRead.nhn?clubid=10833316&boardtype=L&page=1&articleid=2055

2009. 2. 11. 16:10

MSN 메신저를 홈페이지에 달기

 

실시간 상담을 MSN 메신저를 이용하는 방법에 대하여 소개하고자 한다.

운영자는 MSN 메신저 프로그램이 설치 되어 있어야 하며, 홈페이지 방문자는 별도의 프로그램 설치 없이 바로 채팅을 할 수 있다. 불편한 것은 스팸 방지를 위한  코드 인증 부분이 있어 불편하다.  그외에는 어떤 프로그램 보다 효과적이라고 생각한다.

1. 옵션 설정

메신저 설치하기 - http://settings.messenger.live.com/Applications/WebSettings.aspx

MSN 메신저 홈페이지

2. 코드 생성

아래 그림에서 보는 것 처럼 3가지 방식을 지원하며 대화창의 경우는 몇가지 테마를 제공한다. 자동으로 생성된 코드를 복사한다.

MSN 메신저 홈페이지

3. 코드 적용

코드를 그냥 사용하면 새창으로 열리기 때문에 좀 더 보기 좋게 팝업으로 변경하였습니다.

<a href="javascript:;" onclick="javascript:window.open('http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=~~~~~@apps.messenger.live.com&mkt=ko-KR','상담하기','width=400, height=450');");"><img align=middle style="border-style: none;" src="http://messenger.services.live.com/users/~~~~~~@apps.messenger.live.com/presenceimage?mkt=ko-KR" width="16" height="16" /></a>



4. 참고

2009. 2. 11. 16:08

원도우 오류 보고 사용하지 않기

 MS에게 오류보고는 이제 그만 ~
  • 자동으로 재부팅되는 기능 비 활성화 : 내컴퓨터(마우스오른쪽 키 클릭) > 속성 > 고급 > 시작 및 복구 > 설정 > '자동으로 다시 시작'  미사용
  • 오류 보고 창 : 내컴퓨터(마우스오른쪽 키 클릭) > 속성 > 고급 > 오류보고 > '오류 보고 사용 안 함' 선택 > 확인