Record interview questions - Database

Database infrastructure

  1. Install Database
  2. View (How to use, what's the use)
  3. Subqueries, scalar subquery, correlated subqueries

Database operations

  1. Table to create, delete, update
  2. Common Functions
  3. in ascending order by default
select * from tablename order by c2 asc;  #升
select * from tablename order by c2 desc;  #降
select * from tablename order by c1 asc, c2 desc;

problem

  1. ACID - atomicity, consistency, isolation, durability

  2. Primary and foreign keys
    primary key: uniquely identifies each row in the table
    foreign keys: A foreign key is to say with respect to the primary key, is used to establish a link between the tables, the foreign key table is called the primary key master table, having a foreign key table is called the primary table from the table. Used to associate with another table.

    There are two such, user (user) and a table qx (permission) table, user access user in gid id, and is dependent on the gid of qx id. So qx the user id is a foreign key.

  3. Mysql row and table locks (computer lock is a mechanism to coordinate multiple processes or threads of pure concurrent access to a resource)

Table-level locking
Each operation to lock an entire table. Overhead small, locked fast; not deadlock; lock large size, the probability of lock conflicts of the highest, lowest degree of concurrency;
Row-level locking
Lock the row of data for each operation. Large overhead, locking slow; there will be a deadlock; locking the smallest size, lowest probability of lock conflicts, but also the highest degree of concurrency;
  1. Mysql 2 Zhong Storage Engine
    Storage Engine: that is, how to store data, how to create an index for the data storage and how to update, query data and other implementation technologies. Waiting for Oracle and SQL Server databases is only one storage engine. And MySql database offers a variety of storage engines.
    MyISAM is more suitable for read-intensive table, InnoDB is more suitable for write-intensive tables.
MyISAM Features
  • Does not support row locking (MyISAM table locks only), does not support transactions; does not support foreign key; does not support secure recovery after a crash
  • In the table has read queries at the same time, support the insertion of a new record to the table
  • Support for full-text indexing
InnoDB (MySQL default database engine)
  • Row lock support, support services, support for foreign keys, supports safe recovery after a crash
  • It does not support full-text indexing
  1. Mysql default configuration file name: my.cnf
Published 10 original articles · won praise 0 · Views 282

Guess you like

Origin blog.csdn.net/weixin_46178557/article/details/104488382