mysql 사용시 memory DB 사용시 궁금한 점

softpro의 이미지

이번에 memory DB를 사용해볼려고 하는데 몇가지 궁금한점이 있습니다.
1. 메모리 DB 사용시 메모리 DB내용을 다른 MYI등으로 백업이 가능한건지 궁금하구요.
2. create database 로 여러개의 DB 생성이 가능 할까요?
3. 여러 테이블을 JOIN등으로 검색이 가능한지 궁금합니다.

질문에 요지는 일반 MYIAM 방식을 사용할때 와 메모리 DB를 사용할때 차이점이라든지 제약 사항이 궁금 합니다.

sh.의 이미지

mysql에서 메모리(heap) 타입의 테이블에 대한 특징이나 제약사항은 http://dev.mysql.com/doc/refman/4.1/en/memory-storage-engine.html에서 확인하실 수 있습니다.

1처럼 MYI로 저장되길 원하신다면 myisam타입의 테이블을 만드신 후에 insert into myisam select * from memory; 이런식으로 하시면 될것 같고요 (다른 매끈한 방법이 있을런지는 모르겠습니다만)

2번은, memory니 myisam이니 하는것들은 테이블에 대한 이야기이기때문에 메모리 타입의 db를 만드실수는 없습니다.

3은 가능합니다.

sh.의 이미지

잠깐 찾아보니 1번의 경우 http://dev.mysql.com/doc/refman/4.1/en/create-table.html 에 나와있는 CREATE TABLE ... SELECT 를 쓰면 좀더 깔끔하게 해결되겠네요.
아니면 단순히 ALTER TABLE memory_type_table TYPE = MYISAM; 하셔서 myisam 타입으로 변경을 해버리셔도 되고요.

softpro의 이미지

2번째 질문에서 만약에
mysql>create database foo;
mysql> use foo;
그런후에 memory type에 table을 두개 만들고 그리고 다시
mysql>create database baa;
mysql>use baa;
위와 같이 해서 memory type에 table을 두개 만들어서 프로그램에서 두개의 DB에 접속해서 insert, select 와 같은 기능을 할수 없나요?

sh.의 이미지

할 수 있습니다.

softpro의 이미지

답변 감사 합니다. 정말 도움이 많이 된거 같습니다. ^^
다시 한가지 궁금한 점이 있는데요. memory type으로 해서 사용하다가 메모리가 오버 나면 어떻게 되는지 궁금 합니다.

sh.의 이미지

저도 그렇게까지 해본적은 없지만.. 메뉴얼을 찾아보시면 관련된 항목이 있습니다.

# MEMORY table contents are stored in memory, which is a property that MEMORY tables share with internal tables that the server creates on the fly while processing queries. However, the two types of tables differ in that MEMORY tables are not subject to storage conversion, whereas internal tables are:

*If an internal table becomes too large, the server automatically converts it to an on-disk table. The size limit is determined by the value of the tmp_table_size system variable.
*MEMORY tables are never converted to disk tables. To ensure that you don't accidentally do anything foolish, you can set the max_heap_table_size system variable to impose a maximum size on MEMORY tables. For individual tables, you can also specify a MAX_ROWS table option in the CREATE TABLE statement.

대략.. 메모리가 부족하면 임시로 디스크를 사용한다고 하는데, 이렇게까지 할바엔 메모리타입 테이블을 쓰는 의미가 없지 않을까싶네요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.