Database interview questions (1)

What is a database DB (DataBase) database?

A collection of data organized according to a data model and stored in memory

What is a database management system DBMS (DataBase Management System)?

DBMS is a large-scale service software used to manipulate and manage databases DBS.DataBase System – database system: that is, DB+DBMS, refers to a computer system with a database and integrated database management software, refers to a computer with a database and integrated database management software system

What are RDBMSs? relational database management system

Relational Database Management System

The data is stored on the physical storage medium according to the preset organizational structure, and the data can be associated with each other

What are the mainstream database service software? What are the open source and cross-platform database software?

Mainstream database service software includes:

  • MySQL

  • Oracle CorporationOracle

  • IBM DB2

  • Microsoft SQL Server

  • American Sybase Corporation Sybase

  • PostgreSQL developed by the Department of Computer Science at UC Berkeley

open source cross platform

  • MySQL

  • PostgreSQL

Not open source cross-platform

  • Oracle

  • DB2

Not cross-platform and not open source

  • SQL Server

Cross-platform and not open source

  • Sybase

The characteristics of MySQL and the main characteristics of its application

  1. Suitable for small and medium-sized, relational database systems

  2. Support Linux/Unix, Windows and other operating systems

  3. Written in C and C++ for high portability

  4. Support typical application environments such as Python/Java/Perl/PHP through API

LAMP platform

Refers to the combination of a computer system with a database and integrated database management software and Apache HTTP Server

LNMP platform

Refers to the combination of a computer system with a database and integrated database management software and Nginx

What are the parameters related to mysql service?

  • /etc/my.cnf main configuration file

  • /var/lib/mysql database directory

  • The default port number is 3306

  • process name mysqld

  • Transport ProtocolTCP

  • process owner mysql

  • The process belongs to the group mysql

mysql operation instructions and precautions?

  • MySQL instructions: control of environment switching, status checking, exit, etc.

  • SQL instructions: basic considerations for database definition/query/manipulation/authorization statements

  • Operation instructions are not case-sensitive ( except for passwords and variable values )

  • Each SQL command ends or separates with ;

  • Tab key auto-completion is not supported

  • \c can discard the wrong operation command currently written

What are the library management commands?

  • Show databases; // show existing databases

  • Use library name; // switch library

  • Select database(); // Display the current library

  • Create database library name; // Create a new library

  • Drop database library name; // delete library

  • Show tables; // show existing tables

Common Types of Information

  • Numerical type: weight, height, grades, salary

  • Character type: name, work unit, correspondence address

  • Enumeration type: hobbies, gender

  • Date and time type: date of birth, registration time

( numeric ) about integer fields

  • When using UNSIGNED modification, it means that the field corresponding to the computer system with database and integrated database management software only saves positive numbers

  • When the value is not enough to specify the width, it refers to the computer system with a database and integrated database management software to fill in the blanks on the left

  • The width is only the display width, which refers to the computer system with a database and integrated database management software. The size of the stored value is determined by the type

  • When using the keyword ZEROFILL, it refers to a computer system with a database and integrated database management software that fills in zeros instead of blanks

  • When the value is out of range, it means that the computer system with database and integrated database management software reports an error.

(numeric) on floating-point fields

  • Definition format: float( total width, decimal places )

  • When the field value does not match the type, it means that the field value of the computer system with database and integrated database management software is treated as 0

  • When the value is out of range, it means that the computer system with database and integrated database management software only saves the maximum/minimum value

character type

Fixed-length characters: char(number of characters)

  • Maximum length 255 characters

  • When the specified number of characters is not enough, fill it with spaces on the right

  • When the number of characters is exceeded, it means that the computer system with database and integrated database management software cannot write data.

Variable length characters: varchar(number of characters)

  • Allocate storage space according to the actual size of the data

  • When the number of characters is exceeded, it means that the computer system with database and integrated database management software cannot write data.

Large text type:

  • text/blob

  • Use when the number of characters is greater than 65535

enumerated type

  • selects a single value from a given set of values, ENUM

Definition format: enum (value1, value2, valueN)

  • Select one or more values ​​from the given set of values, SET

Definition format: set (value1, value2, valueN)

datetime type

• datetime, DATETIME

– occupies 8 bytes

– Range: 1000-01-01 00:00:00.000000 ~ 9999-12-31 23:59:59.999999

• DATETIME, TIMESTAMP

– Occupies 4 bytes

– Range: 1970-01-01 00:00:00.000000 ~ 2038-01-19 03:14:07.999999

• date, DATE

– Occupies 4 bytes

– Range: 0001-01-01 ~ 9999-12-31

• year, YEAR

– Occupies 1 byte

– Range: 1901~2155

• time, TIME

– occupies 3 bytes

– Format: HH:MM:SS

time function

type use
now() Get the current date and time of the system
year() Dynamically obtain the system date and time during execution
sleep(N) Sleep for N seconds
curdate() Get the current system date
curtime() Get the current system time
month() Get the month in the specified time
date() Get the date at the specified time
time() Get the moment in the specified time

Restrictions

  • Null is allowed to be empty, the default setting

  • NOT NULL is not allowed to be empty

  • Key index type

  • Default sets the default value, the default is NULL

Basic usage of modifying table structure

– ALTER TABLE table name execution action;

  • Add Add field

  • Modify modify field type

  • Change to modify the field name

  • Drop delete field

  • Rename modify table name

What is an index?

  • An index is a method of sorting multiple fields of a recordset.

  • book-like catalog

  • Index types include: Btree, B+tree, hash

Index pros and cons?

Advantages of indexing

  • By creating a unique index, the uniqueness of each row of data in the database table can be guaranteed

  • can speed up the retrieval of data

Index Disadvantages

  • When adding, deleting and modifying the data in the table, the index should also be maintained dynamically.

  • speed of data maintenance

  • Indexes require physical space

There are several key-value types, what are they?

  • INDEX : normal index

  • UNIQUE : unique index

  • FULLTEXT : full-text indexing

  • PRIMARY KEY: primary key

  • FOREIGN KEY : foreign key

INDEX Ordinary Index Description

  • There can be multiple INDEX fields in a table

  • The value of the field is allowed to be repeated, and it can be assigned a NULL value

  • Often the field used as query condition is set as INDEX field

  • The KEY flag of the INDEX field is MUL

primary key primary key considerations

  • There can only be one primary key field in a table

  • The corresponding field values ​​are not allowed to be duplicated, and NULL values ​​are not allowed

  • If multiple fields are used as PRIMARY KEY, it is called composite primary key and must be created together.

  • The KEY flag of the primary key field is PRI

  • Usually used with AUTO_INCREMENT

  • Often set the field that can uniquely identify the record in the table as the primary key field

foreign key foreign key conditions for using foreign keys

  • Let the value of the field in the current table be selected within the range of field values ​​in another table.

    Conditions for using foreign keys

  • The storage engine of the table must be innodb

  • The field type should be consistent

  • The referenced field must be a type of index (primary key)

Briefly describe the components of the MySQL architecture and describe the role of each component.

It mainly includes  8 parts :

  1. Connection pool: process limit, memory check, cache check, etc.

  2. SQL interface: The command sent by the user through the sql client, the sql interface receives the sql operation: (DML data operation language: query, modify, upgrade data, etc.; DDL data definition language: create a new database, new index, delete a user, etc.; stored procedures, view triggers.)

  3. Analyzer: Analyzes query statement transaction object access rights.

  4. Optimizer: optimize access path, generate execution tree.

  5. Caching and buffering: saving sql query results.

  6. Storage engine: a file system used to manage storage, a program that converts logical structures into physical structures; different storage engines have different functions and storage methods.

  7. Management tools: backup, recovery, security, transplantation, clustering, etc. These tools generally deal with the file system and do not need to deal with mysql-server. They correspond to commands.

  8. Physical storage device (file system).

MySQL storage engine

  • Provided as a pluggable component

  The function program that comes with the MySQL service software, the processor for processing tables

  Different storage engines have different functions and data storage methods

  • default storage engine

  MySQL 5.0/5.1 > MyISAM

  MySQL 5.5/5.6+ > InnoDB

Main features of Myisam storage engine

  • Support for table-level locks

  • Does not support transactions, transaction rollbacks, foreign keys

related table files

  • table name.frm,

  • Table name.MYI

  • Table name.MYD

Main features of InnoDB storage engine

  • Supports row-level locking

  • Support transactions, transaction rollback, support foreign keys

related table files

  • xxx.frm

  • xxx.ibd

Finally:  The complete software testing video learning tutorial below has been sorted out and uploaded, and friends can get it for free if they need it【保证100%免费】

insert image description here

 These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too!

软件测试技术交流群社:786229024(里面还有工作内推机会,毕竟我们是关系社会。)

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

How to obtain interview documents:

Guess you like

Origin blog.csdn.net/wx17343624830/article/details/130010024