11 advanced MySQL questions

 
  1. Explain MySQL architecture. - The front layertakes care of network connections and security authentications, themiddle layer does the SQL query parsing, and then the query is handledoff to the storage engine. A storage engine could be either a defaultone supplied with MySQL (MyISAM) or a commercial one supplied by athird-party vendor (ScaleDB, InnoDB, etc.)
  2. Explain MySQL locks. - Table-level locks allow theuser to lock the entire table, page-level locks allow locking ofcertain portions of the tables (those portions are referred to astables), row-level locks are the most granular and allow locking ofspecific rows.
  3. Explain multi-version concurrency control in MySQL.- Each row has two additional columns associated with it - creationtime and deletion time, but instead of storing timestamps, MySQL storesversion numbers.

     

  4. What are MySQL transactions? - A set of instructions/queries that should be executed or rolled back as a single atomic unit.
  5. What’s ACID? - Automicity - transactions areatomic and should be treated as one in case of rollback. Consistency -the database should be in consistent state between multiple states intransaction. Isolation - no other queries can access the data modifiedby a running transaction. Durability - system crashes should not losethe data.
  6. Which storage engines support transactions in MySQL? - Berkeley DB and InnoDB.
  7. How do you convert to a different table type? - ALTER TABLE customers TYPE = InnoDB
  8. How do you index just the first four bytes of the column? - ALTER TABLE customers ADD INDEX (business_name(4))
  9. 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.
  10. How do you prevent MySQL from caching a query? - SELECT SQL_NO_CACHE …
  11. 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 canuse SELECT /* SQL_CACHE */ id FROM … - MySQL will interpret the codeinside comments, while other servers will ignore it.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值