11 advanced MySQL questions

來源:互聯網
上載者:User
 

  1. Explain MySQL architecture
    . - The front layer
    takes care of network connections and security authentications, the
    middle layer does the SQL query parsing, and then the query is handled
    off to the storage engine. A storage engine could be either a default
    one supplied with MySQL (MyISAM) or a commercial one supplied by a
    third-party vendor (ScaleDB, InnoDB, etc.)
  2. Explain MySQL locks
    . - Table-level locks allow the
    user to lock the entire table, page-level locks allow locking of
    certain portions of the tables (those portions are referred to as
    tables), row-level locks are the most granular and allow locking of
    specific rows.
  3. Explain multi-version concurrency control in MySQL
    .
    - Each row has two additional columns associated with it - creation
    time and deletion time, but instead of storing timestamps, MySQL stores
    version numbers.
  4.  

  5. What are MySQL transactions?
    - A set of instructions/queries that should be executed or rolled back as a single atomic unit.
  6. What’s ACID?
    - Automicity - transactions are
    atomic and should be treated as one in case of rollback. Consistency -
    the database should be in consistent state between multiple states in
    transaction. Isolation - no other queries can access the data modified
    by a running transaction. Durability - system crashes should not lose
    the data.
  7. Which storage engines support transactions in MySQL?
    - Berkeley DB and InnoDB.
  8. How do you convert to a different table type?
    - ALTER TABLE customers TYPE = InnoDB
  9. How do you index just the first four bytes of the column?
    - ALTER TABLE customers ADD INDEX (business_name(4))
  10. What’s the difference between PRIMARY KEY and UNIQUE in MyISAM?
    - PRIMARY KEY cannot be null, so essentially PRIMARY KEY is equivalent to UNIQUE NOT NULL.
  11. How do you prevent MySQL from caching a query?
    - SELECT SQL_NO_CACHE …
  12. What’s the difference between query_cache_type 1 and 2?
    - The second one is on-demand and can be retrieved via SELECT SQL_CACHE
    … If you’re worried about the SQL portability to other servers, you can
    use SELECT /* SQL_CACHE */ id FROM … - MySQL will interpret the code
    inside comments, while other servers will ignore it.
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.