Microsoft SharePoint Team Blog
The official blog of the Microsoft SharePoint Product Group
The Records of a Database
Records Fundamentals
Introduction
A table is an object that holds the information of a database. Because a table is the central part of a database, the information it holds must be meticulously organized. To better manage its information, data of a table is arranged in a series of fields called cells. Once a table contains information, you can review it using either SQL Server Management Studio or an external application.
The tables of a database display in the Object Explorer under their database node. To open a table, you can right-click it and click click Open Table.
Table Data Navigation in the SQL Server Management Studio
Data Navigation consists of displaying and viewing data. Because information of a database is stored in tables, your primary means of viewing data consists of opening a table in a view that displays its information.
When a table displays its records, you navigate through its fields using the mouse or the keyboard. With the mouse, to get to any cell, you can just click it. To navigate through records using the keyboard, you can press:
The right arrow key to move to the right cell; if the caret is already in the most right cell, it would be moved to the first cell of the next record, up to the last empty cell of the first empty record
The left arrow key to move to the previous cell; if the caret is in, or reaches, the most left cell of the first record, nothing would happen when you press the the left arrow key
The down arrow key to move to the cell under the current one; if the caret is already in the last cell of the current column, nothing would happen
The up arrow key to move to the cell just above the current one; if the caret is already in the first cell of the current column, nothing would happen
The Page Down to move to the next group of cell that would correspond to the next page; if the number of records is less than a complete page, the caret would move to the last cell of the current column
The Page Up to move to the next group of cell that would correspond to the next page; if the number of records is less than a complete page, the caret would move to the first cell of the current column
Visual Data Entry
Introduction
As you are probably aware already, columns are used to organize data by categories. Each column has a series of fields under the column header. One of the actual purposes of a table is to display data that is available for each field under a particular column. Data entry consists of providing the necessary values of the fields of a table. Data is entered into a field and every time this is done, the database creates a row of data. This row is called a record. This means that entering data also self-creates rows.
There are four main ways you can perform data entry for a Microsoft SQL Server table:
You can use a table from the Object Explorer
You can enter data by typing code in a query window
You can import data from another object or another database
You can use an external application such as Microsoft Access, Microsoft Visual Basic, Borland C++ Builder, Microsoft Visual C++, Borland Delphi, Microsoft Visual Basic, C#, Visual C#, J#, etc.
Using the Object Explorer
Probably the easiest and fastest way to enter data into a table is by using SQL Server Management Studio. Of course, you must first open the desired table from an available database. In the Object Explorer, after expanding the Databases and the Tables nodes, open a table for data entry. If the table does not contain data, it would appear with one empty row. If some records were entered already, their rows would show and the table would provide an empty row at the end, expecting a new record.
To perform data entry on a table, you can click in a field. Each column has a title, called a caption, on top. This gray section on top is called a column header. In SQL Server, it displays the actual name of the column. You refer to the column header to know what kind of data should/must go in a field under a particular column. This is why you should design your columns meticulously. After identifying a column, you can type a value. Except for text-based columns, a field can accept or reject a value if the value does not conform to the data type that was set for the column. This means that in some circumstances, you may have to provide some or more explicit information to the user.
Practical Learning: Introducing Data Entry
Start Microsoft SQL Server, select the appropriate options in the Connect To Server dialog box and connect to the server
Right-click the server name and click New Query
To create a new database, in the empty window, type the following:
CREATE DATABASE WorldStatistics;
GO
USE WorldStatistics;
GO
CREATE TABLE Countries
(
[Country Name] VARCHAR(80),
Area INT,
Population BIGINT,
Capital VARCHAR(50),
[Internet Code] char(2)
);
GO
To execute the SQL statement, press F5
Close the query window
When asked whether you want to save it, click Yes
Type Countries and click Save
In the Object Explorer, right-click the Databases node and click Refresh. Expand the Databases node.
Under Databases, expand WorldStatistics and expand Tables
If you don't see a table named Countries, right-click the Tables node and click Refresh.
Right-click Countries and click Open Table, position the mouse on Open Table and click Return All rows
As the cursor is positioned in the first empty field under CountryName, type Cote d'Ivoire and press Enter
Type 322460 for the area and press Tab
Type 16,393,221 and press Enter
Notice that you receive an error because the commas are not allowed:
Click OK on the error message box.
Change the value to 16393221 People and press Tab
Notice that you receive another error because the column is configured for a natural number and not a string
Click OK on the error message box and delete People
Under Internet Code, type ci and press Enter
Click the field under Capital, type Yamoussoukro and press Enter twice
Complete the table as follows:
source : http://blogs.msdn.com/sharepoint/default.aspx
Minggu, 15 Februari 2009
Langganan:
Postingan (Atom)