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>

번호 제목 글쓴이 날짜 조회 수
25 MySQL 설치 시 checking "LinuxThreads"… "Not found" 에러 발생 시 호스트웨이 2012.09.21 11308
24 [mysql] /tmp/mysql.sock이 없다고 DB접속이 안되는 경우 호스트웨이 2015.09.21 11165
23 Mysql DB 생성 및 사용자 추가 호스트웨이 2012.03.23 11144
22 MySQL Table 상태 확인, 복구 및 최적화 호스트웨이 2015.09.11 10870
21 MySQL 원격 접속이 이뤄지지 않는다면? 호스트웨이 2012.07.13 10736
20 chive – phpMyAdmin 보다 좋은 ! 호스트웨이 2012.05.18 10621
19 mysql replication을 이용한 DB 백업 동기화 에러 발생시 (slave db 1062 error) 호스트웨이 2015.09.09 8976
18 MySQL 보안을 위한 전용관리계정으로 MySQL 관리하기 호스트웨이 2015.09.08 8950
17 [mysql] table 백업 호스트웨이 2015.09.21 7798
16 Client does not support authentication protocol requested by server 메시지 발생 시 호스트웨이 2012.10.18 7603
15 MYSQL 동시접속자수 늘리기 호스트웨이 2015.09.18 7312
14 [Oracle] 대량 자료 조회 Parallel 호스트웨이 2015.09.26 7237
13 mysql-5.5.x 에서 character-set 변경 호스트웨이 2012.12.07 7199
12 [MySQL] 쿼리 한 번으로 데이터베이스 용량 알아내기 file 호스트웨이 2012.11.16 7151
11 [mysql] 작은 용량의 파일 로드 속도가 느려진 경우 호스트웨이 2015.09.22 7102
10 MySQL에서 Query Cache 사용하기 호스트웨이 2012.12.20 7085
9 [MySQL] 무한정 늘어나는 log-bin 파일 줄이기 호스트웨이 2012.11.23 7050
8 MySQL DB 옵티마이저 사용법 호스트웨이 2015.09.18 6854
7 Mysql에서 log-slow-queries 로그 남기기 호스트웨이 2012.09.21 6808
6 phpmyadmin에서 'mcrypt 확장모듈을 불러올 수 없습니다' 에러 시 file 호스트웨이 2012.11.29 6656