Computer three-level database review 5-database and database objects

Future Education Chapter 7 Topic Notes_Database and Database Objects

2. Indexing is an effective means to speed up the query. The general format is:
CREATE [UNIQUE] INDEX<index name>
ON <table name> (<column name> [<order>], <column name> [<order>] …) INCLUDE (attribute name)
WHERE constraint
3. The data table has UNIQUE constraint and PRIMARY constraint for the uniqueness of a data column in the data table.
PRIMARY KEY constraints mostly emphasize that the same element cannot appear in the primary key, but you want to force one or more columns The combination (not the primary key) must use UNIQUE as one item. UNIQUE constraint allows null values, PRIMARY KEY constraint does not allow null values
4. When creating a new database, the size of the main data file in the user database cannot be less than the size of the model database.
5. Clustered (set) index refers to the index organization in which the order of index items is consistent with the physical order of records in the table.
6. In the database, a commonly used serial number is usually set using the identity field, and the advantage is that it will not be repeated , And it's unique.
7. Steps
to create an indexed view: ①Use the SCHEMABINDIND clause to create a view.
It can only refer to the base table in the same database, instead of other standard views.
All referenced functions must be deterministic, rowset functions, derived tables, None of the subqueries can be used in indexed views.
② Create a unique index on the view
③ Create a non-clustered index based on the needs of the clustered index.
④Create and use the indexed view
8. The code corresponding to FILENAME in the ALTER DATABASE command needs to be enclosed in single quotes. If FILEGROWTH is added with %, it is a percentage. If% is omitted, the database system uses MB by default.
12, the index view can improve the performance of the following query types:
① the polymerization process and the large number of rows of coupling
② often connected to many queries and aggregation operations
③ decision support workloads
not improve following:
① a large number of write operations OLTP systems
② having a large number of The updated database
③ does not involve aggregation or connection query
④ The GROUP by key has a high cardinality of aggregation. High cardinality means that the column contains many different values. When the column value followed by GROUP by contains many different values, resulting in the same number of rows in the view graph and table, then the index view for this column cannot be improved.
13. If the arrangement order of the data records in the data file is the same as the index item in the index file If the arrangement order of is consistent, the index file is called a clustered index. The record in the index structure is composed of the index column value and its corresponding pointer.
14. The main extension of the data file of the user database is MDF
15. The difference between classification and clustering is that the classification knows in advance which categories can be divided, and the clustering does not know in advance which category it will be divided into, and a clustering algorithm is required to automatically determine .
16. Each database has a master data file and several slave files. The file is the physical manifestation of the database.
17. Each database must have at least one log file, or there can be multiple log files. Log files are not included in the file group, and a file cannot be a member of multiple file groups.
18. When separating the database, not only separate the database files, but also separate the log files together. The log file is an important part of the attached database. Log space and data space are managed separately, but they can be placed on the same disk or on different disks.
19. The essence of the partition table is to store data subsets that meet different standards in one or more file groups in a certain database, and use the original data to express the logical address of the data storage.
20. CLUSTERED indicates that a clustered index is established, that is, the order of index items is consistent with the physical order recorded in the table.
NONCLUSTERED is a non-clustered index.
22. Secondary data files can be placed in the primary file group.
24. Whether to create a partition table mainly depends on the current data size of the table and the future data size, and also depends on how to operate the data in the table.
25. The method of creating a unique clustered index through the view can save the result set of the view in the database. This kind of view is called an indexed view, also known as an indexed view.
27. The recommended extension of the primary data file is .mdf, and the recommended extension of the secondary data file is .ndf. If the file group to which the data file belongs is not specified when the data file is defined, the newly created data file will be assigned to the default file group.
28. The job information of the SQL server instance is stored in the msdb database. A job is a collection of a series of automatically executed operations defined in SQLserver, and the execution of the job does not require any manual intervention.
29. The number of file groups specified when creating a partition scheme should not be less than the number of partitions generated by the partition function.
32. The size of a database log file and the size of the data file are not related.
37. The steps to create a partition table are to create a partition function and create a partition. Scheme, use the partition scheme to create a table;
the purpose of creating a partition function is to tell the database management system how to partition the table;
the role of creating a partition scheme is to map the partition generated by the partition function to the file group.
Different partitions can be mapped to the same database file.
40. When the number of rows in the table is far greater than the number of indexes, using this method can significantly speed up the query speed of the table. For compound indexes:
①For a table, if there is a compound index, there is no need to create a single index at the same time.
②If the query conditions require, you can add a compound index when there is a single index.
③For composite indexes, it is best to use the order of where conditions as the order of the index columns.
41. When deleting the architecture, if the CASCADE option is used, all the architecture objects in the architecture will be deleted together. If the RESTRICT option is used, if the If the deleted schema contains schema objects, then refuse to delete this schema.
The names of tables in different schemas of the same database can be the same.
43. The tempdb database will be re-created every time SQLserver is started, so if it is damaged, there is no need to restore it.
44. The minimum size of the main data file cannot be less than 3MB.
45. The PRIMARY file group is a file group defined by the system, which contains the main data files and any other data files that are not clearly assigned to other file groups. All pages of the system tables are allocated in the main file group. Log files are not included in the file group.
46. ​​CAREATE PARTITION FUNCTION PF1(int) AS RANGE LEFT FOR VALUES(...n), the number of partitions created is n+1, and the LEFT keyword specifies the boundary when the specified partition interval is arranged from left to right in ascending order by the database engine The interval is on the left. (0,1],(1,100),(100,200],(20,...)
47. Use CAREAT to create a database, ALTER to modify, and DROP to delete a database.
49. When a user creates a database, the system automatically changes the data in the model database. All contents are copied to the newly created database.
50. Log files are not included in the file group. Log files and data files are managed separately.
53, tempdb database is used to save temporary objects or intermediate result sets, local and global temporary tables created by users Are automatically placed in the database.
54. The architecture (mode) is the next logical namespace of the database, which can store database objects such as tables and views. A database can contain multiple schemas. The schema name in the same database must be the same. The schema name can be displayed or the default name provided by the DBMS.
59. A table can only have one clustered index, because there is only one case for the physical order of a table.
The purpose of the clustered index is to speed up data query
64, delete the user syntax in the database: DROP User U1
68, you can declare one or more parameters when creating a stored procedure, unless the default value of the parameter is defined or the parameter is set equal to Another parameter, otherwise the user must provide a value for each declared parameter when calling the stored procedure. A stored procedure can have up to 2100 parameters.
A stored procedure can have multiple output parameters, not multiple input parameters.
69. If the automatic growth method is not set when the database is created, the database may not have enough space after being used for a period of time. If the data space is insufficient, no more data can be inserted, and the log space is insufficient, indicating that no more modifications can be made to the database.
Ways to expand the database space:
①Expand the size of the existing files in the
database ②Add new files to the database
70. The SQL statement to create the partition scheme is:
CREATE PARTITION SCHEMA …1
AS PARTITION …2
[ALL] TO ({,…n })
…n specifies the file group name used to hold the partition specified by …1.
73. The files contained in the database and the file storage location information are all stored in the main data file.
78. Looking at the sname column of the student table, create a non-clustered index:
CREATE NONCLUSTERED INDEX idx1 ON (student(sname))

mind Mapping

Insert picture description here

Guess you like

Origin blog.csdn.net/TOPic666/article/details/115018363