Get the App
SLTechnology News&Howtos  ›  Database  › 

The creation of tables in SQL server Database and the manipulation of data tables using T-SQL statements

Shulou Source: shulou.com Published: 2022-06-01 12:42:49 10月02日 Update

The creation of tables and the use of T-SQL statements one, table creation and basic concepts A table is a database object that contains all the data in the database, and the table definition is a collection. Data is organized in a table similar to that in a spreadsheet, both in row and column format. Each row represents a unique record, and each column represents a field in the record. The table in SQLserver contains the following major components * columns: each column represents a property of the object modeled by the table, for example, a product table has id column, color column and weight column # rows: each row represents a separate instance of the object modeled by the table

Data type

Creation of tables

Manipulate the datasheet using T-SQL statements

1. Inquire about Wang Ming's achievements? Result: Wang Ming 90

Select name, score from student-1 name = 'Wang Ming'

2. Add 2 points to Wang Ming?

Update student-1 set score = score + 2 where name = 'Wang Ming'

3. Query the students whose remarks are not empty?

Select from student-1 where remarks is not null

4. inquire about the students whose scores are more than 95 points?

Select from student-1 where score > 95

5. Wang Ming transferred to another school and deleted Wang Ming.

Delete from student-1 where name = 'Wang Ming'

Here comes a new classmate whose name is Wang Guonan.

Insert into student-1

Values (20par 'Wang Guonan', '11111111111111''3' 95' running')

7. Inquire about the GPA?

Select avg (grade) as GPA

From student-1

8. Inquire about Zhang?

Select * from student-1

Where name like 'Zhang%'

9. Delete all data using truncate

Truncate table student-1

Write so many examples just in the hope that you can learn and use them. In this case, the student score sheet is used to demonstrate. If you change to other tables, the grammar is the same. This article only explains the basic T-SQL statements, and will continue to update the use of T-SQL statements in the future.

Tags: Grades Wang Ming data name query statement representative student object database one line just remarks kingdom datasheet similarity product example classmate name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Shulou Information Linux OPPO Reno