'개발'에 해당되는 글 73건

  1. 2011.12.12 [eclipse plug-in] properties 에디터
  2. 2011.11.15 Git 개념설명 및 사용법 정리
  3. 2011.11.15 Git 자주쓰는 명령들 정리..
  4. 2011.09.07 아스키코드표 ( ascii code table )
  5. 2011.09.07 XML에서 사용할수 없는 문자들 : unicode control characters
  6. 2011.08.18 apache 서버 설치 하기
  7. 2011.08.11 JSTL 버전별 사용 환경 및 사용 설정
  8. 2010.10.14 rsh 사용을 위한 설정과 사용법
  9. 2010.10.07 SQL 학습을 위한 기본 table 생성 스크립트 2
  10. 2010.09.30 [MySQL] NOW() 함수와 SYSDATE() 함수

[eclipse plug-in] properties 에디터

개발 2011. 12. 12. 21:14

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

다국어를 처리하기 위해서 문자열 리소스를 properties 로 저장하면,  아래처럼 한글의 경우 알수없는 글자로 보인다.


press.tvReport=TV\ub9ac\ud3ec\ud2b8

이럴경우 propeditor를 설치해주면 된다.

Eclipse상단 메뉴의 Help -> Install New Software -> Add버튼 클릭하여 Name에 propedit 입력하고 Location에 http://propedit.sourceforge.jp/eclipse/updates/ 를 입력후 "OK"를 클릭하여 Update 사이트를 추가한다.


여러가지가 있는데, Properties Editor만 체크하고 설치한다. (이것만 있으면 됨 )

설치후에도 정상적으로 안보이면,
마우스 오른쪽 버튼을 눌러서 "Open with"에서 PropertiesEditor로 선택되어 있는지 확인한다.

편하기 하기위해서 editor를 지정하자.
Preference -> General -> Editors -> File Associations 에서 확장자 .properties에 방금 설치한 에디터가 default로 되어 있는지 확인하자.




:

Git 개념설명 및 사용법 정리

개발 2011. 11. 15. 18:26

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


:

Git 자주쓰는 명령들 정리..

개발 2011. 11. 15. 16:05

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


누가 잘 정리해 놓은게 있어서 여기에 다시 저장..


git config --global user.name [user name]  -> 작업자 이름 설정

git config --global user.email [user email]   -> 작업자 이메일 설정

git config --global --list                              -> 설정값(이름 및 메일등 ) 확인

 


git init  -> git 저장소(repo) 만들기

 

git remote add [remote name] [remote addres]  -> 별명으로 원격지주소를 저장

git remote rm [remote name]                            -> 별명의 원격지를 삭제

git remote rename [remote name] [new name]  -> 별명을 새로운 별명으로 변경

 

git fetch [remote name]  -> remoet의 모든 정보를 가져옴(모든 branch)

 

git pull    -> 저장소에서 변경 내용 가져오기
 

git push  -> commit들을 master 저장소에 저장

git push [remote name] [localbranch name]   -> local branch의 내용을 업데이트

git push [server] tag [TAG]                           -> server에 tag 전송

git push [server] --tags                                 -> 변경된 모든 tag 전송

git push [server] [L.B]:[R:B]                         -> server 에 local branch 를

                                                                       -Remote branch이름으로저장

 

git tag [TAG NAME]           -> 저장소에 태그를 붙인다.

git tag                               -> 태그목록을 본다.

git branch [branch name]   -> 저장소의 branch name으로 branch를 만든다.

git branch                          -> branch 목록을 본다.

git branch -a                     -> 현재 생성된 모든 local branch와 reomte branch 확인

 

git checkout [branch name]       -> 다른 브랜치로 전환

git checkout -b [branch name]   -> branch 생성

git checkout [file or folder]         -> git repo 기준 마지막 commit 상태로 돌림

git checkout [id] [file or folder]  -> git repo 기준 id에 해당하는 commit 상태로 돌림

git checkout -f                          -> 아직 commit 되지 않은 working tree와 -index 수정정사항
                                                  모두 사라짐

 

git merge [branch name]    -> branch의 내용을 가져와 합침

 

git add [file or folder]          -> git에 file 또는 folder 추가

git add *                            -> git에 모든 file 또는 folder 추가

 

git rm [file or folder]           -> git 파일 또는 폴더 제거

 

git status                           -> 현재 git 상태 보기

git commit -m [message]  -> message를 repo에 저장

 

git diff                               -> local과 remote의 차이점을 보여줌

 

git remote                         -> remote서버 확인


 



:

아스키코드표 ( ascii code table )

개발 2011. 9. 7. 12:54

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Char

Hex

Oct

Dec

  

Char

Hex

Oct

Dec

Ctrl-@ NUL

00

000

0

NUL (null문자)

Space

20

040

32

Ctrl-A SOH

01

001

1

SOH (헤더개시)

!

21

041

33

Ctrl-B STX

02

002

2

STX (텍스트 개시)

"

22

042

34

Ctrl-C ETX

03

003

3

ETX (텍스트 종료)

#

23

043

35

Ctrl-D EOT

04

004

4

EOT (전송종료)

$

24

044

36

Ctrl-E ENQ

05

005

5

ENQ (조회)

%

25

045

37

Ctrl-F ACK

06

006

6

ACK (수신 OK)

&

26

046

38

Ctrl-G BEL

07

007

7

BEL (경고) a

'

27

047

39

Ctrl-H BS

08

010

8

BS (후퇴) b

(

28

050

40

Ctrl-I HT

09

011

9

HT (수평탭) t

)

29

051

41

Ctrl-J LF

0A

012

10

LF (개행) n

*

2A

052

42

Ctrl-K VT

0B

013

11

VT (수직탭) v

+

2B

053

43

Ctrl-L FF

0C

014

12

FF (새페이지) f

,

2C

054

44

Ctrl-M CR

0D

015

13

CR (복귀) r

-

2D

055

45

Ctrl-N SO

0E

016

14

SO (Shift Out)

.

2E

056

46

Ctrl-O SI

0F

017

15

SI (Sift In)

/

2F

057

47

Ctrl-P DLE

10

020

16

DEL (자료링크 이스케이프)

0

30

060

48

Ctrl-Q DCI

11

021

17

DIC1 (장치제어 1)

1

31

061

49

Ctrl-R DC2

12

022

18

DIC2 (장치제어 2)

2

32

062

50

Ctrl-S DC3

13

023

19

DIC3 (장치제어 3)

3

33

063

51

Ctrl-T DC4

14

024

20

DIC4 (장치제어 4)

4

34

064

52

Ctrl-U NAK

15

025

21

NAK (수신실패)

5

35

065

53

Ctrl-V SYN

16

026

22

SYN (동기)

6

36

066

54

Ctrl-W ETB

17

027

23

ETB (전송블록 종료)

7

37

067

55

Ctrl-X CAN

18

030

24

DAN (취소)

8

38

070

56

Ctrl-Y EM

19

031

25

EM (매체종료)

9

39

071

57

Ctrl-Z SUB

1A

032

26

SUB (치환)

:

3A

072

58

Ctrl-[ ESC

1B

033

27

ESC (이스케이프)

;

3B

073

59

Ctrl-\ FS

1C

034

28

FS (파일분리)

<

3C

074

60

Ctrl-] GS

1D

035

29

US (유닛분리)

=

3D

075

61

Ctrl-^ RS

1E

036

30

SP (공백)

>

3E

076

62

Ctrl_ US

1F

037

31

US (유닛분리)

?

3F

077

63

 

 

Char

Hex

Oct

Dec

Char

Hex

Oct

Dec

@

40

100

64

`

60

140

96

A

41

101

65

a

61

141

97

B

42

102

66

b

62

142

98

C

43

103

67

c

63

143

99

D

44

104

68

d

64

144

100

E

45

105

69

e

65

145

101

F

46

106

70

f

66

146

102

G

47

107

71

g

67

147

103

H

48

110

72

h

68

150

104

I

49

111

73

i

69

151

105

J

4A

112

74

j

6A

152

106

K

4B

113

75

k

6B

153

107

L

4C

114

76

l

6C

154

108

M

4D

115

77

m

6D

155

109

N

4E

116

78

n

6E

156

110

O

4F

117

79

o

6F

157

111

P

50

120

80

p

70

160

112

Q

51

121

81

q

71

161

113

R

52

122

82

r

72

162

114

S

53

123

83

s

73

163

115

T

54

124

84

t

74

164

116

U

55

125

85

u

75

165

117

V

56

126

86

v

76

166

118

W

57

127

87

w

77

167

119

X

58

130

88

x

78

170

120

Y

59

131

89

y

79

171

121

Z

5A

132

90

z

7A

172

122

[

5B

133

91

{

7B

173

123

\

5C

134

92

|

7C

174

124

]

5D

135

93

}

7D

175

125

^

5E

136

94

~

7E

176

126

_

5F

137

95

DEL

7F

177

127





:

XML에서 사용할수 없는 문자들 : unicode control characters

개발 2011. 9. 7. 11:41

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


XML로 데이터를 보내고 있는데, XML에 포함될수 없는 문자들이 있네요.

이클립스에서는 아래와같이 에러문구를 보여줍니다.

An invalid XML character (Unicode: 0xb) was found in the CDATA section


XML 스펙을 찾아보면 1.0에서는 CDATA 섹션에도 들어갈수 없는 문자들이 있고, 1.1에서는 가능하다고 하네요.
보통 아래처럼 XML 1.0 으로 쓰고 있었는데... 이런 함정이 숨어 있을줄이야..

<?xml version="1.0" encoding="UTF-8"?>

두가지 해결방법이 있습니다.
첫번째는, 아래같은 로직을 이용해서 문제를 회피할수 있습니다.

public String filterBadXMLCharactors(String textToFilter) {
  StringBuffer filteredString = new StringBuffer();
  char current;

  if (textToFilter == null || "".equals(textToFilter)) {
   return "";
  }

  for (int i = 0; i < textToFilter.length(); i++) {
   current = textToFilter.charAt(i);

   if ((current == 0x9) || //
    (current == 0xA) || //
    (current == 0xD) || //
    ((current >= 0x20) && (current <= 0xD7FF)) || //
    ((current >= 0xE000) && (current <= 0xFFFD)) || //
    ((current >= 0x10000) && (current <= 0x10FFFF))) {
    filteredString.append(current);
   }
  }
  return filteredString.toString();
 }


두번째는,
CDATA 섹션에 데이터를 인코딩해서 넣는 것입니다. CDATA에는 바이너리도 넣을수 있는줄 알았는데 아니었어요.

두번째 해결방법이 더 좋은 방법인데, 주고받는쪽 둘다 고쳐야 됩니다.



:

apache 서버 설치 하기

개발 2011. 8. 18. 22:10

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1. 아파치 서버를 다운 받는다.
wget http://mirror.apache-kr.org/httpd/httpd-2.2.19.tar.gz

tar -xvzf httpd-2.2.19.tar.gz

2. 환경설정

cd httpd-2.2.19
./configure --prefix=/home1/irteam/apps/httpd-2.2.19

make

make install

3. 아파치 환경파일 백업

cd conf

cp httpd.conf httpd.conf.original


4. 아파치 환경파일 수정

vi httpd.conf





:

JSTL 버전별 사용 환경 및 사용 설정

개발 2011. 8. 11. 16:58

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
아파치에서 퍼온내용이다.
버전별로 필요한 항목이 적용되어 있다. 

1.2 버전은 tomcat 6.0 부터 사용가능하다.
1.1 버전은 tomcat 5.5 부터 사용가능하다.


JSP(tm) Standard Tag Library implementations

Apache hosts the Apache Standard Taglib, an implementation of the JSP Standard Tag Library (JSTL) specification. Various versions are available.

Version JSTL version Requirements Getting the Taglib
Standard 1.2 JSTL 1.2 (not yet JCP approved) Servlet 2.5, JavaServer Pages 2.1 svn
Standard 1.1 JSTL 1.1 Servlet 2.4, JavaServer Pages 2.0 download
Standard 1.0 JSTL 1.0 Servlet 2.3, JavaServer Pages 1.2 download

News

Date Item
2009/04/22 Moved to a Maven based build system.
2008/12/21 A patch from Robert Goff has moved the trunk of the Standard Taglib up towards JSTL 1.2 level.
10/25/2004 Standard Taglib version 1.1.2 - A minor bug fix update - is now available.
07/20/2004 Standard Taglib version 1.1.1 released - A minor bug fix update - is now available.
01/30/2004 Standard Taglib version 1.1.0 - First official release of our implementation of JSTL 1.1 - is now available.
09/25/2003 Standard Taglib version 1.1.0-B1 - early access (Beta 1) of our implementation of JSTL 1.1 - is now available.


jstl 1.1 의 경우
/WEB-INF/lib/
여기에 jstl.jar, starndard.jar 파일을 위치 시킨다.
/WEB-INF/web.xml 에
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
 <taglib>
<taglib-uri>http://java.sun.com/jstl/fn</taglib-uri>
<taglib-location>/WEB-INF/tld/fn.tld</taglib-location>
</taglib> 
</jsp-config>

jsp 페이지에는
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
를 위줄에 써준다.





:

rsh 사용을 위한 설정과 사용법

개발 2010. 10. 14. 15:56

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

"manager서버"는 rsh를 실행하는 서버이다.
"target서버"는 원격지의 서버로 관리당하는 서버이다.


1. 일단 target서버에 rsh, rsh-server의 설치가 필요하다.
    yum명령으로 간단하게 설치할수 있다.

$ yum search rsh
================================================== Matched: rsh ==================================================
lam.i386 : LAM (Local Area Multicomputer) 프로그래밍 환경.
lam.x86_64 : LAM (Local Area Multicomputer) 프로그래밍 환경.
fonts-sinhala.noarch : Fonts for Sinhala
openssh.x86_64 : The OpenSSH implementation of SSH protocol versions 1 and 2
rsh.x86_64 : 원격 액세스 명령에 사용되는 클라이언트 (rsh, rlogin, rcp).
rsh-server.x86_64 : 원거리 접속 명령어 (rsh, rlogin, rcp) 에 사용되는 서버.
tcp_wrappers.i386 : TCP 데몬에 사용되는 wrapper로서 활동하는 보안 도구.
tcp_wrappers.x86_64 : TCP 데몬에 사용되는 wrapper로서 활동하는 보안 도구.

$ yum install tcp_wrappers.x86_64

(확인방법)

$ rpm -qa | grep rsh
rsh-0.17-38.el5
rsh-server-0.17-38.el5


2. 이제 Centos 자체에서 설정을 할 차례이다.
target서버에서 어떠한 ip를 허용할 것인지 지정하도록 한다.

/root/.rhosts 에 허용할 ip를 적는다.
/home1/irteam/.rhosts 에 허용할 ip를 적는다.
10.24.9.xxx

.rhosts파일은 보안을 위해서 퍼미션을 변경한다.

# chmod 600 .rhosts


3. 이제 rsh와 rlogin을 활성화( on ) 시킨다.

# chkconfig --level 35 rlogin on
# chkconfig --level 35 rsh on
(활성화 확인)
# chkconfig --list | grep rlogin
# chkconfig --list | grep rsh

4. xinetd 에서도 활성화 한다.

# vi /etc/xinetd.d/rlogin
# default: on
# description: rlogind is the server for the rlogin(1) program.  The server \
#       provides a remote login facility with authentication based on \
#       privileged port numbers from trusted hosts.
service login
{
        socket_type             = stream
        wait                    = no
        user                    = root
        log_on_success          += USERID
        log_on_failure          += USERID
        server                  = /usr/sbin/in.rlogind
        disable                 = no  ( 요기를 no로 변경 )
}

rsh, rlogin을 추가해준다.

# vi /etc/securetty에 rsh, rlogin을 추가해준다.
console
vc/1
vc/2
#vc/3
#vc/4
#vc/5
#vc/6
#vc/7
#vc/8
#vc/9
#vc/10
#vc/11
tty1
tty2
#tty3
#tty4
#tty5
#tty6
#tty7
#tty8
#tty9
#tty10
#tty11
rsh
rlogin

그리고 xinetd를 재시작한다.

# service xinetd restart

5. 비밀번호 없이 들어오도록  수정

# vi /etc/pam.d/rlogin
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rlogin" must be
# listed in /etc/securetty.
auth       sufficient   pam_nologin.so
auth       sufficient   pam_securetty.so
auth       sufficient   pam_env.so
auth       sufficient   pam_rhosts_auth.so
auth       include      system-auth
account    include      system-auth
password   include      system-auth
session    optional     pam_keyinit.so    force revoke
session    include      system-auth


# vi /etc/pam.d/rsh
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rsh" must be
# listed in /etc/securetty.
auth       sufficient   pam_nologin.so
auth       sufficient   pam_securetty.so
auth       sufficient   pam_env.so
auth       required     pam_rhosts_auth.so
account    include      system-auth
session    optional     pam_keyinit.so    force revoke
session    include      system-auth

설정이 완료 되었다.


manager 서버에서는 아래와 같이 실행해면된다.
cmd 부분을 따옴표로 감싸야 파라미터도 같이 전달된다.

# rsh target-ip cmd
# rsh masyncserver 'touch /home1/iretam/test.txt'

참고로 rsh는 보안에 취약하므로 주의해서 사용해야 한다.



:

SQL 학습을 위한 기본 table 생성 스크립트

개발 2010. 10. 7. 15:57

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

해당 sql 스트립트의 출처 : http://www.forta.com/books/0672325675/

teach yourself 10 이라는 책에 나오는 예제이다.
MySQL용 스트립트 입니다.   ( 링크에서는, 각종 DB별로 스트립트를 구할수 있다. )



-------------------------
-- Create Customers table
-------------------------
CREATE TABLE Customers
(
  cust_id      char(10)  NOT NULL ,
  cust_name    char(50)  NOT NULL ,
  cust_address char(50)  NULL ,
  cust_city    char(50)  NULL ,
  cust_state   char(5)   NULL ,
  cust_zip     char(10)  NULL ,
  cust_country char(50)  NULL ,
  cust_contact char(50)  NULL ,
  cust_email   char(255) NULL
);

--------------------------
-- Create OrderItems table
--------------------------
CREATE TABLE OrderItems
(
  order_num  int          NOT NULL ,
  order_item int          NOT NULL ,
  prod_id    char(10)     NOT NULL ,
  quantity   int          NOT NULL ,
  item_price decimal(8,2) NOT NULL
);


----------------------
-- Create Orders table
----------------------
CREATE TABLE Orders
(
  order_num  int      NOT NULL ,
  order_date datetime NOT NULL ,
  cust_id    char(10) NOT NULL
);

------------------------
-- Create Products table
------------------------
CREATE TABLE Products
(
  prod_id    char(10)      NOT NULL ,
  vend_id    char(10)      NOT NULL ,
  prod_name  char(255)     NOT NULL ,
  prod_price decimal(8,2)  NOT NULL ,
  prod_desc  text          NULL
);

-----------------------
-- Create Vendors table
-----------------------
CREATE TABLE Vendors
(
  vend_id      char(10) NOT NULL ,
  vend_name    char(50) NOT NULL ,
  vend_address char(50) NULL ,
  vend_city    char(50) NULL ,
  vend_state   char(5)  NULL ,
  vend_zip     char(10) NULL ,
  vend_country char(50) NULL
);


----------------------
-- Define primary keys
----------------------
ALTER TABLE Customers ADD PRIMARY KEY (cust_id);
ALTER TABLE OrderItems ADD PRIMARY KEY (order_num, order_item);
ALTER TABLE Orders ADD PRIMARY KEY (order_num);
ALTER TABLE Products ADD PRIMARY KEY (prod_id);
ALTER TABLE Vendors ADD PRIMARY KEY (vend_id);


----------------------
-- Define foreign keys
----------------------
ALTER TABLE OrderItems ADD CONSTRAINT FK_OrderItems_Orders FOREIGN KEY (order_num) REFERENCES Orders (order_num);
ALTER TABLE OrderItems ADD CONSTRAINT FK_OrderItems_Products FOREIGN KEY (prod_id) REFERENCES Products (prod_id);
ALTER TABLE Orders ADD CONSTRAINT FK_Orders_Customers FOREIGN KEY (cust_id) REFERENCES Customers (cust_id);
ALTER TABLE Products ADD CONSTRAINT FK_Products_Vendors FOREIGN KEY (vend_id) REFERENCES Vendors (vend_id);


아래는 추가로 데이터 생성 스크립트이다.
---------------------------
-- Populate Customers table
---------------------------
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000001', 'Village Toys', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'John Smith', 'sales@villagetoys.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact)
VALUES('1000000002', 'Kids Place', '333 South Lake Drive', 'Columbus', 'OH', '43333', 'USA', 'Michelle Green');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000003', 'Fun4All', '1 Sunny Place', 'Muncie', 'IN', '42222', 'USA', 'Jim Jones', 'jjones@fun4all.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000004', 'Fun4All', '829 Riverside Drive', 'Phoenix', 'AZ', '88888', 'USA', 'Denise L. Stephens', 'dstephens@fun4all.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact)
VALUES('1000000005', 'The Toy Store', '4545 53rd Street', 'Chicago', 'IL', '54545', 'USA', 'Kim Howard');

-------------------------
-- Populate Vendors table
-------------------------
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('BRS01','Bears R Us','123 Main Street','Bear Town','MI','44444', 'USA');
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('BRE02','Bear Emporium','500 Park Street','Anytown','OH','44333', 'USA');
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('DLL01','Doll House Inc.','555 High Street','Dollsville','CA','99999', 'USA');
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('FRB01','Furball Inc.','1000 5th Avenue','New York','NY','11111', 'USA');
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('FNG01','Fun and Games','42 Galaxy Road','London', NULL,'N16 6PS', 'England');
INSERT INTO Vendors(vend_id, vend_name, vend_address, vend_city, vend_state, vend_zip, vend_country)
VALUES('JTS01','Jouets et ours','1 Rue Amusement','Paris', NULL,'45678', 'France');

--------------------------
-- Populate Products table
--------------------------
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BR01', 'BRS01', '8 inch teddy bear', 5.99, '8 inch teddy bear, comes with cap and jacket');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BR02', 'BRS01', '12 inch teddy bear', 8.99, '12 inch teddy bear, comes with cap and jacket');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BR03', 'BRS01', '18 inch teddy bear', 11.99, '18 inch teddy bear, comes with cap and jacket');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BNBG01', 'DLL01', 'Fish bean bag toy', 3.49, 'Fish bean bag toy, complete with bean bag worms with which to feed it');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BNBG02', 'DLL01', 'Bird bean bag toy', 3.49, 'Bird bean bag toy, eggs are not included');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('BNBG03', 'DLL01', 'Rabbit bean bag toy', 3.49, 'Rabbit bean bag toy, comes with bean bag carrots');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('RGAN01', 'DLL01', 'Raggedy Ann', 4.99, '18 inch Raggedy Ann doll');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('RYL01', 'FNG01', 'King doll', 9.49, '12 inch king doll with royal garments and crown');
INSERT INTO Products(prod_id, vend_id, prod_name, prod_price, prod_desc)
VALUES('RYL02', 'FNG01', 'Queen doll', 9.49, '12 inch queen doll with royal garments and crown');

------------------------
-- Populate Orders table
------------------------
INSERT INTO Orders(order_num, order_date, cust_id)
VALUES(20005, '2004-05-01', '1000000001');
INSERT INTO Orders(order_num, order_date, cust_id)
VALUES(20006, '2004-01-12', '1000000003');
INSERT INTO Orders(order_num, order_date, cust_id)
VALUES(20007, '2004-01-30', '1000000004');
INSERT INTO Orders(order_num, order_date, cust_id)
VALUES(20008, '2004-02-03', '1000000005');
INSERT INTO Orders(order_num, order_date, cust_id)
VALUES(20009, '2004-02-08', '1000000001');

----------------------------
-- Populate OrderItems table
----------------------------
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20005, 1, 'BR01', 100, 5.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20005, 2, 'BR03', 100, 10.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20006, 1, 'BR01', 20, 5.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20006, 2, 'BR02', 10, 8.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20006, 3, 'BR03', 10, 11.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20007, 1, 'BR03', 50, 11.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20007, 2, 'BNBG01', 100, 2.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20007, 3, 'BNBG02', 100, 2.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20007, 4, 'BNBG03', 100, 2.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20007, 5, 'RGAN01', 50, 4.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20008, 1, 'RGAN01', 5, 4.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20008, 2, 'BR03', 5, 11.99);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20008, 3, 'BNBG01', 10, 3.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20008, 4, 'BNBG02', 10, 3.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20008, 5, 'BNBG03', 10, 3.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20009, 1, 'BNBG01', 250, 2.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20009, 2, 'BNBG02', 250, 2.49);
INSERT INTO OrderItems(order_num, order_item, prod_id, quantity, item_price)
VALUES(20009, 3, 'BNBG03', 250, 2.49);



:

[MySQL] NOW() 함수와 SYSDATE() 함수

개발 2010. 9. 30. 14:23

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
현재의 시간을 구하는 2개의 함수가 있다.

NOW()
SYSDATE()

차이점은 무엇일까?
아래의 쿼리를 보면 알수 있다.

SELECT NOW(), SLEEP(2), NOW();
SELECT SYSDATE(), SLEEP(2), SYSDATE();

짐작이 되는가?

결과를 보자..

SELECT NOW(), SLEEP(2), NOW();
2010-09-30 14:18:35 0 2010-09-30 14:18:35

SELECT SYSDATE(), SLEEP(2), SYSDATE();
2010-09-30 14:18:35 0 2010-09-30 14:18:37


그렇다.. SYSDATE는 함수가 실행되는 순간의 시간이고, NOW는 쿼리가 실행되는 순간의 시간이다.
간단한 차이지만, SYSDATE를 사용할때 발생할수 있는 문제점은 뭐가 있을까?

한가지는, Replication이다. 리플리케이션으로 구성되어 있을때, SYSDATE를 사용하면 입력된 시간이 Master/Slave의 시간이 다를수가 있게된다. 그래서 사용시 주의가필요하다.


: