Linux DB

mysql help tables 사용해서 공부하기

2008.07.25 02:05

jook 조회 수:23223

1. http://dev.mysql.com/ 페이지에 접속해서 Developer Zone -> Documentation 메뉴로 들어가면, MySQL Help Tables 라는 메뉴에서 자신이 사용하는 버전의 help tables압축 파일을 다운로드 받는다.

2. 다운로드 받은 파일의 압축을 풀면 help tables의 dump 파일인 fill_help_tables-버전.sql 파일이 생기게 된다. 이 파일을 mysql 서버에 업로드 하고, 아래와 같이 mysql db에 sql 파일의 내용을 업데이트 한다.

[root@localhost src]# /usr/local/mysql/bin/mysql mysql < fill_help_tables-5.1.sql

3. 데이터 업데이트를 완료한 후 mysql 서버에 접속하면 mysql db 내에 help_category, help_keyword, help_relation, help_topic 네개의 table이 생성된다.  

[root@localhost /root]# /usr/local/mysql/bin/mysql -u root -p mysql
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.1.24-rc-log Source distribution

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
23 rows in set (0.00 sec)

mysql>

4. 이제 본격적으로 help table을 이용해서 mysql 공부를 시작 할 수 있다.. ^^
help 다음에 쿼리문의 일부분을 입력하면 해당 쿼리의 사용법 등에 대한 설명이 나온다. (예제까지.. ^^)

    ex) help select -> select의 사용법이 출력된다.
          help like -> 쿼리문중 like 구문의 사용법이 출력된다.

mysql> help select
Name: 'SELECT'
Description:
Syntax:
SELECT
    [ALL | DISTINCT | DISTINCTROW ]
      [HIGH_PRIORITY]
      [STRAIGHT_JOIN]
      [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
      [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
    select_expr, ...
    [FROM table_references
    [WHERE where_condition]
    [GROUP BY {col_name | expr | position}
      [ASC | DESC], ... [WITH ROLLUP]]
    [HAVING where_condition]
    [ORDER BY {col_name | expr | position}
      [ASC | DESC], ...]
    [LIMIT {[offset,] row_count | row_count OFFSET offset}]
    [PROCEDURE procedure_name(argument_list)]
    [INTO OUTFILE 'file_name' export_options
      | INTO DUMPFILE 'file_name'
      | INTO var_name [, var_name]]
    [FOR UPDATE | LOCK IN SHARE MODE]]

SELECT is used to retrieve rows selected from one or more tables, and
can include UNION statements and subqueries. See [HELP UNION], and
http://dev.mysql.com/doc/refman/5.1/en/subqueries.html.

The most commonly used clauses of SELECT statements are these:

o Each select_expr indicates a column that you want to retrieve. There
  must be at least one select_expr.

o table_references indicates the table or tables from which to retrieve
  rows. Its syntax is described in [HELP JOIN].

o The WHERE clause, if given, indicates the condition or conditions
  that rows must satisfy to be selected. where_condition is an
  expression that evaluates to true for each row to be selected. The
  statement selects all rows if there is no WHERE clause.

  In the WHERE clause, you can use any of the functions and operators
  that MySQL supports, except for aggregate (summary) functions. See
  [HELP =].

SELECT can also be used to retrieve rows computed without reference to
any table.

URL: http://dev.mysql.com/doc/refman/5.1/en/select.html


mysql> help count
Name: 'COUNT'
Description:
Syntax:
COUNT(expr)

Returns a count of the number of non-NULL values of expr in the rows
retrieved by a SELECT statement. The result is a BIGINT value.

COUNT() returns 0 if there were no matching rows.

URL: http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html

Examples:
mysql> SELECT student.student_name,COUNT(*)
    ->        FROM student,course
    ->        WHERE student.student_id=course.student_id
    ->        GROUP BY student_name;

mysql> help like
Name: 'LIKE'
Description:
Syntax:
expr LIKE pat [ESCAPE 'escape_char']

Pattern matching using SQL simple regular expression comparison.
Returns 1 (TRUE) or 0 (FALSE). If either expr or pat is NULL, the
result is NULL.

The pattern need not be a literal string. For example, it can be
specified as a string expression or table column.

URL: http://dev.mysql.com/doc/refman/5.1/en/string-comparison-functions.html

Examples:
mysql> SELECT 'David!' LIKE 'David_';
        -> 1
mysql> SELECT 'David!' LIKE '%D%v%';
        -> 1

mysql>

번호 제목 글쓴이 날짜 조회 수
45 MySQL Table 이 깨졌을 때 복구하는 방법 호스트웨이 2012.03.16 18670
44 심볼릭 링크를 이용한 mysql 데이터 디렉토리 위치 변경 호스트웨이 2012.03.23 14318
43 Mysql DB 생성 및 사용자 추가 호스트웨이 2012.03.23 11144
42 MySQL-5.5 설치하기 호스트웨이 2012.04.27 15711
41 show processlist의 state 종류 호스트웨이 2012.05.11 19275
40 chive – phpMyAdmin 보다 좋은 ! 호스트웨이 2012.05.18 10621
39 안전한 MySQL 접속하기 file 호스트웨이 2012.06.22 13056
38 MySQL 테이블 구조만 백업받아두기 호스트웨이 2012.06.29 26888
37 Mysql banchmark tool – sysbanch 설치하기 호스트웨이 2012.07.06 11543
36 MySQL 원격 접속이 이뤄지지 않는다면? 호스트웨이 2012.07.13 10736
35 mysql 로그 삭제하기 호스트웨이 2012.07.20 11497
34 Mysql - 원격 접속 지연 발생시 호스트웨이 2012.08.03 14015
33 Mysql slow-query를 이용한 로그 분석 호스트웨이 2012.08.10 27695
32 리눅스에서 MYSQL 데이터 디렉토리 변경 호스트웨이 2012.08.31 20791
31 Mysql - mysqldump시 LOCK TABLES 오류 호스트웨이 2012.09.07 25110
30 Mysql에서 log-slow-queries 로그 남기기 호스트웨이 2012.09.21 6815
29 MySQL 설치 시 checking "LinuxThreads"… "Not found" 에러 발생 시 호스트웨이 2012.09.21 11309
28 Client does not support authentication protocol requested by server 메시지 발생 시 호스트웨이 2012.10.18 7604
27 mysql 4.0 에서 4.1 다운그레이드 호스트웨이 2012.11.01 6616
26 [MySQL] 쿼리 한 번으로 데이터베이스 용량 알아내기 file 호스트웨이 2012.11.16 7155