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 hostname-bin.000 로그 화일 관리 sylee 2008.06.11 22507
44 리눅스에 큐브리드 설치하기 file 호스트웨이 2008.09.03 22013
43 mysql4.1.x -> mysql4.0.x 로 옮기기 sylee 2008.05.15 21451
42 리눅스에서 MYSQL 데이터 디렉토리 변경 호스트웨이 2012.08.31 20791
41 [팁] Mysql 설치시 LinuxThreads 에러 메세지 sylee 2009.01.02 19488
40 My SQL 사용자 추가 호스트웨이 2008.05.19 19265
39 show processlist의 state 종류 호스트웨이 2012.05.11 19262
38 mysql의 table이 깨졌다는 메시지가 출력됩니다. sylee 2008.05.15 18875
37 MySQL Table 이 깨졌을 때 복구하는 방법 호스트웨이 2012.03.16 18665
36 DB접속시 DNS 관련 오류 호스트웨이 2015.09.25 18276
35 Ubuntu mysql 삭제/재설치 호스트웨이 2015.09.04 16828
34 MySQL-5.5 설치하기 호스트웨이 2012.04.27 15711
33 심볼릭 링크를 이용한 mysql 데이터 디렉토리 위치 변경 호스트웨이 2012.03.23 14315
32 Mysql - 원격 접속 지연 발생시 호스트웨이 2012.08.03 14014
31 MariaDB, MySQL 의 InnoDB 엔진 백업 솔루션 xtrabackup 호스트웨이 2015.05.07 13867
30 안전한 MySQL 접속하기 file 호스트웨이 2012.06.22 13055
29 MySQL Bash 스크립트를 활용한 로컬 백업 호스트웨이 2016.02.04 12402
28 MYSQL의 "too many connections" 에러 해결법 호스트웨이 2015.09.10 11793
27 Mysql banchmark tool – sysbanch 설치하기 호스트웨이 2012.07.06 11543
26 mysql 로그 삭제하기 호스트웨이 2012.07.20 11497