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] 무한정 늘어나는 log-bin 파일 줄이기 호스트웨이 2012.11.23 7058
24 phpmyadmin에서 'mcrypt 확장모듈을 불러올 수 없습니다' 에러 시 file 호스트웨이 2012.11.29 6660
23 mysql-5.5.x 에서 character-set 변경 호스트웨이 2012.12.07 7201
22 MySQL에서 Query Cache 사용하기 호스트웨이 2012.12.20 7088
21 innodb 설치 및 옵션 호스트웨이 2014.04.14 23376
20 MariaDB, MySQL 의 InnoDB 엔진 백업 솔루션 xtrabackup 호스트웨이 2015.05.07 13867
19 Ubuntu mysql 삭제/재설치 호스트웨이 2015.09.04 16828
18 MySQL Processlist 콘솔 상에서 확인 호스트웨이 2015.09.07 6060
17 MySQL 보안을 위한 전용관리계정으로 MySQL 관리하기 호스트웨이 2015.09.08 8957
16 MYSQL-날짜 관련 함수 모음 호스트웨이 2015.09.09 40688
15 mysql replication을 이용한 DB 백업 동기화 에러 발생시 (slave db 1062 error) 호스트웨이 2015.09.09 8981
14 MYSQL의 "too many connections" 에러 해결법 호스트웨이 2015.09.10 11793
13 MySQL Table 상태 확인, 복구 및 최적화 호스트웨이 2015.09.11 10902
12 지정된 시간 이상 질의를 계속 하는 질의문 잡아내기 호스트웨이 2015.09.15 6042
11 MYSQL 동시접속자수 늘리기 호스트웨이 2015.09.18 7321
10 MySQL DB 옵티마이저 사용법 호스트웨이 2015.09.18 6858
9 [mysql] shell 자동화 호스트웨이 2015.09.20 6329
8 [mysql] table 백업 호스트웨이 2015.09.21 7801
7 [mysql] /tmp/mysql.sock이 없다고 DB접속이 안되는 경우 호스트웨이 2015.09.21 11173
6 [mysql] sqli, pdo 설정 확인 호스트웨이 2015.09.22 6597