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

View mode and T-SQL statement operation to manage SQL Server database

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

For the related theoretical concepts of SQL Server database, please refer to: basic concepts of SQL Server database, table and data type.

View mode management table

There are two ways for SQL Server to operate on the database, namely, visual operation interface and SQL language. The following describes how to easily and quickly create, modify and delete the table structure and add, modify and delete the data in the table by using the mouse and keyboard in the SSMS visual interface.

1. Create Table 1) Open SSMS, then expand the database class, right-click the "Table" node, and select "New"-> "Table" command from the pop-up shortcut menu.

2) enter the column name of the first column is "number", the data type is "int", and uncheck the "allow Null value" check box (empty is not allowed)

3) set the identification specification for the column. In the properties tab on the right, select "identity column" as "number", thus setting the "number" to identify the column.

4) create the columns "course", "course number", "credits", "teacher", "place", "start time", "end time" and "remarks" respectively, and set "course number" as the primary key. Right-click "course number" to pop up the shortcut menu and select it as the primary key. After the setting is successful, the "yellow key" will be displayed on the left, as shown in the following figure:

5) after the setup is complete, save the table, as shown in the following figure, right-click the table name, select "close" command from the pop-up shortcut menu, and the system will prompt "Save changes to the following?" Click the yes button and enter the table name "sourse"

2. Modify the table structure

If you need to modify the table structure, such as adding or deleting fields in the table, you need to redesign the table. Right-click the table "db.sourse" in SSMS and choose "Design" from the pop-up shortcut menu.

3. Edit the table

After the table is created, you can add or delete data from the table. Right-click the table "db.sourse", select "Edit the first 200 rows" from the pop-up shortcut menu, and then insert, update or delete data from the table.

4. Delete the table

If you need to delete the table, you can right-click the table "db.sourse" and choose "Delete" from the pop-up shortcut menu.

II. T-SQL statement management table

The operation of SQL Server can also be done using T-SQL statements, which is the most commonly used method for database management in actual production environments. The execution of T-SQL statements is usually carried out in the query window. Select the database class and click the "New query" button in the SSMS toolbar to create a new query window.

1. Create the sourse table create table sourse (No. Int identity (1) not null, name nvarchar (50) not null, ID number varchar (18) primary key, Job nvarchar (50) not null, date of birth datetime not null, Base salary money not null check (Base salary > = 0 and Base salary gouse benet) Gocreate table sourse (No. Int identity (1) not null, name nvarchar (50) not null, ID No. Varchar (18) primary key, Job nvarchar (50) not null, date of birth datetime not null, basic salary money not null check (basic salary = 0 and basic salary insert into sourse (name, ID number, position, date of birth, base salary) values ('Zhang San', '1111111111111111' manager', '2001and1127014000) Goinsert into sourse (name, ID card number, job title, date of birth, base salary) values ('Mary', '22222222222222),' waitress', '2003x7xx 5x5); goinsert into sourse (name, identity card number, job title, date of birth, base salary) values (' Zhao Liu', '3333333333333333', 'supervisor', '19983993333333333) Goinsert into sourse (name, ID card number, job title, date of birth, basic salary) values ('Sun Wu', '4444444444444444) (' cleaning', '1996Candle 24mm 2500); goselect * from sourse; goalter table sourse add age nvarchar (3); goalter table sourse alter column job title varchar (10); goalter table sourse drop column age; godrop table sourse

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