Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database and table management

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Database file type:

① data file

Main data file: suffix .MDF, one and only one, created by default, containing startup information and data objects

Secondary data file: suffix .ndf, can have any one, default none

File stream data: storing pictures, audio and other files

② transaction log file: suffix .ldf, at least one, created by default, a SQL statement that records all transactions, using the

In restoring the database

2. Create and expand the database

File size: has an initial size, expandable, minimum unit 1MB

Growth mode: ① by percentage ② by MB

Data size can be limited: method: ① limit size ② does not limit size

3. Shrink the database: free up unused space

Method: ① manual contraction

Shrink the database: cannot be lower than the initial size

Shrink file: can be lower than the initial size, the smallest unit is 1m

② automatic contraction

Database properties, which can be set for automatic contraction

4. Detach and attach databases

Detach: remove the database from the instance to make it easier to move or copy the database

Attach: add a database to the instance

Delete: remove the database from the instance and delete the data file, only the user database can be deleted

5. Data type:

Exact number: int: integer

Bit: there are only 0 or 1 or NULL values, and only 0 and 1 values can be entered

Decimal: numeric

Money: currency valu

Approximate numbers: float, real

String: char: fixed length, specified column length

Varchar: variable length, specify maximum size

Text: large number of characters

Nchar, nvarchar, ntext: Unicode character, double byte

Binary characters: binary

Date and time: date date time time datetime date and time

6. Create tables:

① column name ② data type ③ whether null values are allowed or not these three points are necessary

④ default value: no value specified for the column, use default value

⑤ identifier column: a column that automatically generates ordinal values, which cannot be entered or changed, and there can be at most one.

Three elements: the data type is numerical

Seeds: initial valu

Increments: step size, growth valu

⑥ check constraints (check): limit acceptable values

⑦ sets the primary key

⑧ set foreign key

7. Insert data:

Insert into table name values ('value 1', 'value 1', 'value 2', 'value', etc. )

8. Update the data:

Update table name set column name = 'new value' where condition

9. Delete data:

① delete: you can conditionally delete part of the data, save the log, restore it, do not reset the identity column, and delete it with foreign keys.

Constrained data table

② truncate: can only empty the entire table, do not save the log, cannot be recovered, reset the identity column to 0, and cannot delete the foreign key.

List of bundles

Command: delete from table name where condition

Truncate table table name

10. Delete libraries and tables:

Drop database library name

Drop table table name

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report