블로그 이미지
다엄
잘해야지

calendar

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

Notice

    'Programming/mySQL'에 해당되는 글 4

    1. 2010.06.11 create, select, delete, update 기본 쿼리문
    2010. 6. 11. 19:15 Programming/mySQL

    오랜만에 해서 그런지 완전 처음부터 쿼리를 짜려고 하니 기억이 가물가물하다.
    정리도 할 겸 기록해둬야겠다.

    // 테이블 생성
    create table table_name(
     `Idx` int(5) NOT NULL auto_increment,
     `Item1` varchar(10) character set utf8 collate utf8_general_ci NOT NULL,
     `Item2` varchar(10) character set utf8 collate utf8_general_ci NOT NULL,
     `Item3` bool,
     `Item4` double(5,2),
     PRIMARY KEY(`Idx`),
     FOREIGN KEY(Item1) references Anothor_Table_Name 

    )ENGINE=MyISAM DEFAULT CHARSET=utf8;

    // 테이블의 데이터 지우기
    TRUNCATE TABLE table_name;
    DELETE * FROM table_name;

    // 테이블에 값 입력
    insert into table_name values (NULL, "src", "tar");

    // 테이블 갱신
    update table_name set Item2 = "target" where Item1 = "src";

    // 테이블 자료 가져오기
    select item1, item2 from table_name where item1 = "src" and item2 = "tar";
    posted by 다엄
    prev 1 2 3 4 next