1. 程式人生 > >第三周數據庫翻譯

第三周數據庫翻譯

types val involved nis allow cto keep var 單選

1.It’s worth noting that a lot of

people will never need to create their own database.You may never create your own tables or other data structures either.

You may only ever run backups and restores and manipulate the security on the system and let application installs create databases for you.That’s completely understandable and perfectly in line with the needs of many businesses and many accidental DBAs.However, it’s a good idea to understand what this stuff is and how it works as part of understanding SQL Server.

1.值得一提的是許多人不需要去創建自己數據庫。你可能也從不會創建自己的桌面和其他的數據結構。.你也許只運行備份、恢復和維護系統的安全性並且在應用程序安裝時為你創建數據庫。那是完全可以理解的而且符合許多商人和臨時的數據庫的需要。然而,理解這件事情是一個好主意和理解數據庫的一部分是如何工作的

2.A Database Is Actually Files

You need to store information that you want to be able to retrieve later. It’s necessary that you organize that information. If you were working with a word processing program, you store different documents in different files. You really wouldn’t put all of your documents into a single, large file. SQL Server functions in a very similar manner. While you have a server, you’re not going to simply store all the various types of information necessary to run your business in one large pile within that server. Instead you’re going to organize that information. The initial organizational mechanism for SQL Server is the database. A database allows you to keep sets of information in separate storage areas. Further it allows you to isolate the security for those different sets of information so that you can control who gets to see or modify that data.

2.數據庫是一個真實的文件

你需要你的信息以後可以檢索。整理信息是必要的。如果你在做一個一個文字處理程序,你要儲存不同的文檔在不同的文件裏。你不會將所有文件放入一個大文件裏 ,SQL server 有一個十分相似的功能。當你有一個服務器,你不會簡單地存儲所有所需的各種類型的信息在一個大型的服務器裏運行你的業務。相反,你要組織這些信息。這些組織原理機制一開始來自於SQL server 數據庫。數據庫允許你輸入的信息在不同的存儲區域。它允許你進一步對於信息的安全分離,這樣你可以控制誰可以看到或修改數據。

3.Within a database there are these things called tables. Tables are how the relational storage gets defined. The information that you’ve organized for storage in a given database will be added to these tables. You will be able to add or remove data to the database by way of these tables. You’ll also be able to retrieve the information from the database from these tables.

3.這些東西在數據庫中稱為表。表是表示存儲是怎麽定義的。在給定的數據庫中儲存信息會被添加到表中。你可以通過這些表來向數據庫中添加和移動數據。你也可以在表中搜索數據庫中的信息。

4.In addition to tables in the database, there are a number of different constructs that will help you manage the information within your database that are also stored within the database. These include a number of different types of objects that help you manipulate the data such as views, stored procedures and functions. You also get a full set of security objects such as roles and users.

4.除了數據庫中的表之外,還有許多不同的構造可以幫助您管理數據庫中的信息,這些信息也存儲在數據庫中。其中包括許多不同類型的對象,這些對象可以幫助您操作諸如視圖、存儲過程和函數等數據。您還可以得到一組完整的安全對象,如角色和用戶。

5.Databases are actually made up of files that are stored somewhere on the Windows file system. These files are in a proprietary, binary format and cannot be read directly except through SQL Server. Writing data to these files is one of the most expensive and time consuming operations within SQL Server (although in most cases, the time involved is measured in microseconds). Because of this expense, it’s important to understand that your databases are defined by files and that it matters where they are stored as part of your understanding of the database.

5.數據庫實際上是由儲存在Windows文件系統裏的文件組成的。這些數據是以二進制的形式存儲的並且不能被直接讀取除了通過數據庫。在數據庫中把這些文件寫成數據是最昂貴和耗時的操作(即使在大多數情況下,這些復雜的時間是以微秒衡量的)。因為這種花費,理解你的數據庫是如何通過文件定義的是重要的並且它們作為你理解數據庫的一部分被儲存在哪裏也是重要的。

6.Two Types of Files

You could simply store your data in a text file or a spreadsheet and plenty of people do. But when you need multiple people to access it at the same time, updating some of the date, deleting some, inserting new information, all at the same time, those other storage mechanisms become very problematic. That’s why you need to use a database. Because SQL Server has to do so much different kinds of work with the data that it’s storing, it’s come up with some different mechanisms for performing those actions. Databases are structured around two different types of files that store different kinds of information . You can refer to this figure as we go through the two types.

NOTE: There are actually several other file types that can be added to a database, but we’re talking fundamentals here, so we’ll keep it straight forward and simple for now.

6.兩種類型的文件

你可以簡單地將你的數據存儲在一個文本文件或表格,並且很多人這樣做。但是當你需要多人同時訪問它,更新的日期,刪除一些,插入新的信息的時候,那些其他存儲機制變得非常有問題。這就是為什麽你需要使用一個數據庫。因為SQL Server有許多的不同種類的工作與數據存儲,並提出了一些不同的機制來執行這些操作。數據庫是圍繞兩種不同類型的文件存儲來儲存不同種類的信息。當我們討論這兩個類型時,你可以參考這裏的數據。

註意:還有其他文件類型,可以添加到一個數據庫,但是我們這裏說的基礎,所以現在簡單直接的說明。

7.Data File

The first type of file needed to define your database is the data file. The data file is easy to understand and explain. This type of file is where the information that you write to your database is going to be stored. Any given database can be made up of multiple data files. The data files can be placed on more than one hard drive with your system. If you have more advanced storage mechanisms, such as Storage Area Networks (SAN), you may have other constructs than simple hard drives on a server, but they will be mapped to the Windows operating system as drives and SQL Server can use those for storage of the data files as well.

7.定義數據庫所需的第一種文件是數據文件。數據文件很容易理解和解釋。這種類型的文件是您寫入數據庫的信息將要存儲的地方。任何給定的數據庫都可以由多個數據文件組成。數據文件可以被放置在您的系統的多個硬盤上。如果你有更先進的存儲機制,如存儲區域網絡(SAN),你可能有其他構造簡單的服務器上的硬盤,但他們將作為驅動器映射到Windows操作系統和SQL服務器可以使用這些存儲的數據文件。

8.Log File

The second type of file needed to create a database is the log file. A log file is a slightly more complex thing to understand than the data file. A log file records every transaction that takes place within the database. A transaction occurs when data is manipulated in some way within the system. These manipulations can be updates to existing data, adding new data by inserting it into a table, or deletes of data from tables. All these actions cause information to be written to the log file. There are a number of other functions also associated with the log file. These files are usually much smaller than the data files because the entries into the log file only need to be kept around until all the data has been successfully written to the data file. Because writing to the data file is subject to different kinds of failures, log files are kept to help deal with those failures. Once information has been written to the data file, the log entry can be removed. The process to clean up log files will be discussed in detail in another post.

8.創建數據庫所需的第二種文件是日誌文件。日誌文件比數據文件稍微復雜一點。日誌文件記錄在數據庫中發生的每一個事務。當數據在系統中以某種方式被操縱時,就會發生事務。這些操作可以對現有數據進行更新,通過將新數據插入到表中,或者從表中刪除數據來添加新數據。.所有這些操作都會將信息寫入日誌文件。還有許多其他函數也與日誌文件有關。這些文件通常比數據文件小得多,因為日誌文件中的條目只需要保存,直到所有數據都成功寫入數據文件。因為寫入數據文件會受到不同類型的失敗,所以保存日誌文件以幫助處理這些失敗。一旦信息寫入數據文件,日誌條目就可以被刪除。清理日誌文件的過程將在另一個帖子中詳細討論。

9.When you’re initially creating the files you can adjust their size. You can adjust that size, both up and down, after creating the files as well. Each file can also be set to grow automatically and this is complicated enough so it’s worth spending a little more time understanding exactly what it means.

9.你可以調整它們的尺寸當你最初創建這些文件時,你也可以在創建這些文件之後來回調整它的尺寸。每個文件也可以被設置成自動變化,這是足夠復雜的因此花費點時間理解它準確意味著什麽是值得的。

10.Autogrowth settings

Managing files on databases can be a lot of work if you have a lot of databases. You’ll have to check for the available space and then set the files to larger sizes when there is enough. One way around all this manual work is to use the autogrow property settings on the database.

10.自動增長設置

數據庫可以在管理文件中做大量的工作,如果你有很多的數據庫。你必須檢查可用空間,來保證輸入文件的空間足夠。在本手冊所有工作的方法之一是使用上的自動增長屬性設置數據庫。

11.A word of caution: Be very careful using this setting. You can fill a drive and cause your server to go offline.

Setting a database to autogrow means that the database will automatically adjust the file size upwards when it starts to run out of room. Many people use this setting and many applications set it to on when they’re installed. You should set an upper growth limit on the files in order to avoid that problem. You can set the files to grow by a percentage of the database or in fixed sizes. For smaller databases, growing by percentages can work, but as the database expands in size, growing by percentages becomes a longer and longer process. The best practice is to set the growth to a particular value instead of a percentage. The details on how to set all these will be covered when databases get created.

11.註意:使用這個設置時要非常小心。您可以填充驅動器並使您的服務器脫機。將數據庫設置為autogrow意味著數據庫在開始運行時將自動調整文件大小。許多人使用這個設置,許多應用程序在安裝時設置它。為了避免這個問題,您應該設置文件的上增長限制。您可以通過數據庫或固定大小的百分比來設置文件。對於較小的數據庫,按百分比增長是可行的,但隨著數據庫規模的擴大,以百分比增長的過程將變得更長更長的過程。最佳實踐是將增長設置為特定值,而不是百分比。關於如何設置所有這些的細節將在數據庫被創建時覆蓋。

12.Where to place your files

When you install SQL Server, you have the option of defining where your database files will be placed. You can also adjust this through the Server Properties window. It’s always best to know where you are going to be placing files when you create a database in order to be sure that you have enough space on that drive. To see this location, connect to your server as was outlined in Database Fundamentals #2. Once connected, in the Object Explorer window, right click on the server name itself. This will bring up a context menu. Select the “Properties” menu choice at the bottom of that menu. This will open the Server Properties window and you will be in the default, “General”, tab. Select the “Database Settings” tab and you will see something very similar to this:

12.當您安裝SQL Server時,您可以選擇定義數據庫文件的位置。您還可以通過服務器屬性窗口進行調整。當您創建一個數據庫時,最好知道您將在哪裏放置文件,以確保您在該驅動器上有足夠的空間。要查看此位置,請與您的服務器連接,如數據庫基礎2所述。在連接後,右鍵單擊服務器名稱本身。這將彈出一個上下文菜單。在菜單的底部選擇“Properties”菜單選項。這將打開服務器屬性窗口,您將處於默認的“General”選項卡中。選擇選項卡,您將看到與此類似的東西:

13.The interesting area to look at here is at the bottom of the window in the section titled Database default locations. You’ll see three different directories listed, one each for Data, Log and Backup. By clicking on the ellipsis at the right side of the entry you can bring up a default file browser window to make a change to the default location of your log or data files. You can also modify them by typing directly into the text box with either a physical path as shown above or using a Universal Naming Convention (UNC) path.

13.有趣的地方是看這個在窗口的底部被命名為數據錯誤位置的部分。你將看到三個不同的列成表的引導,在數據,記錄,備份中的一個。通過點擊入口的右邊的省略號,你可以提出一個瀏覽器窗口的錯誤文件來改變你的記錄和數據文件的錯誤的位置。你也可以通過在這個文本框直接輸入來修改它們用上面展示的物理路線或使用一個通用的名為公約路線。

14.The goal for placing files should be to attempt to separate functionality as much as you can. If you have the capability, you’re better off separating your operating system files from your data and log files. This means placing the data and log files on something other than the C:\ drive, if possible. Further, you should at least consider storing the data and log files on completely separate drives as well. This allows for the maximum throughput of data to the files on the drives.

14.放置文件的目標應該是盡可能地分離功能。如果有能力,最好將操作系統文件與數據和日誌文件分離。這意味著,如果可能的話,將數據和日誌文件放在驅動器以外的其他東西上。此外,至少應該考慮將數據和日誌文件存儲在完全獨立的驅動器上。這允許對驅動器上的文件進行數據的最大吞吐量。

15.Once you’ve determined that the storage location is appropriate, if you’ve made changes, click on the OK button to save those changes. If you haven’t made any changes, or you don’t wish to save the changes you made, click the Cancel button. Either of these clicks will close the Server Properties window.

15.如果您已經進行了更改並確定了存儲位置是適當的,那麽單擊OK按鈕來保存這些更改。如果您沒有做任何更改,或者您不希望保存所做的更改,請單擊Cancel按鈕。這兩種單擊都將關閉服務器屬性窗口。

16.Each of the two file types have several properties in addition to the physical location that will matter when you create your databases. Part of the physical location will be the file name and extension. These can be any valid Windows operating system name and extensions. By default the extensions will usually be .mdf for the data file and .ldf for the log file. You can change these if you want, but it could lead to confusion since most people use the defaults as a best practice. There is a logical file name that allows you to refer to the file for operations within the database without having to refer back to the full file location including the drive. The logical name does not have to match the physical name at all, but usually they do.

16.在創建數據庫是,除了物理位置之外,這兩種文件類型中的每個都具有多個屬性。物理位置的一部分將是文件名和擴展名。這些都是有效的窗口操作系統名字和擴展。默認情況下擴展通常是用於數據文件的mdf和用於日誌文件的idf。如果你願意,你可以改變這些。但這可能會導致混淆,因為大多是人使用這些錯誤作為一個最好的鍛煉。有一個邏輯文件名稱允許你引用該文件的操作當在數據庫中不需要引用包括驅動器在內的完整文件位置。邏輯名稱不一定要與物理名稱匹配,但是通常是這樣。

17.Conclusion

That introduces the guts of the file storage for databases. Next post we’re going to actually create a database on the server, which is a heck of a lot easier than this post makes it feel like.

17.結論

這就介紹了數據庫文件存儲的本質。下一篇文章,我們將在服務器上實際創建一個數據庫,這比這篇文章要簡單得多。

Share this:

  • Twitter
  • Facebook
  • Reddit
  • LinkedIn26
  • Tumblr
  • Pocket
  • Email

2 Comments

  • 18.Francesco Mantovani

Interesting, but how files are stored into the file system?
Few days ago I imported a .txt file of 200MB size and once imported into SQL Server the size was up to 500MB.
Why this difference?

June 20, 2017 at 4:47 pm

Reply

18.有趣但這些文件是如何儲存到文件系統中的呢?幾天前我輸入了一個200MB的文本文件之前輸入到數據庫中的大小超過了500MB。為什麽不同?

  • 19.Grant Fritchey

The files on the operating system are just files. Nothing special. As to how your text file went from 200mb to 500mb, without a lot more details, I’m only going to offer some speculation. First up, data types. Let’s say you have CHAR(500) defined (just making stuff up) and the actual data largely only consists of 30-50 characters in length. You’ll have an additional 450 characters stored. Another possible data type issue, let’s say you’re defining NVARCHAR instead of VARCHAR (pretty common). NVCHAR stores twice as much in size as the actual data, so 200mb can easily become 400mb. Also, you’re not talking about whether that data storage is just the data or the data and the log. A transaction can be as large as the data that’s moved through, larger even sometimes. All of that can add up to show more data than is strictly observed just by the size of some text in a text file. There are lots of other possible causes, so don’t get hung up on these examples.

June 21, 2017 at 7:34 am

Reply

OK, fine, but what do you think?

19.操作系統上的文件只是文件沒什麽特別的。至於您的文本文件如何從200mb到500mb,沒有更多的細節,我只會提供一些猜測。首先,數據類型。假設您已經定義了CHAR(500)(只是把數據編出來),實際的數據在很大程度上只包含30-50個字符。您將額外存儲450個字符。另一種可能的數據類型問題,假設您定義的是nv替代VARCHAR(相當常見)。NVCHAR存儲的大小是實際數據的兩倍,因此200mb很容易變成400mb。此外,您並不是在討論數據存儲只是數據,還是數據和日誌。事務可以像移動的數據一樣大,甚至有時更大。所有這些都可以顯示出更多的數據,而不僅僅是文本文件中某些文本的大小。還有很多其他可能的原因,所以不要掛在這些例子上。

2017年6月21日上午7:34

好吧,但是你覺得呢?

摘自https://www.scarydba.com/2017/06/20/database-fundamentals-3-whats-database/

作者:Grant Fritchey, Microsoft Data Platform MVP

第三周數據庫翻譯