Creation of tables and use of T-SQL statements
一,表的创建与基本概念 表是包含数据库中所有数据的数据库对象,表定义是一个集合。数据在表中组织方式与在电子表格中相似,都是按行和列的格式组织的。每一行代表一条唯一的记录,每一列代表记录中的一个字段。**SQLserver 中的表包含下列主要组件 ** #列: 每一列代表由表的建模的对象的某个属性,列如,一个产品表有id 列,颜色列和重量列 #行: 每一行代表由表建模的对象的一个单独的实例
Data Type
Creation of tables
Manipulating data tables with T-SQL statements
1, query Wang Ming's results? Result: Wang Ming 90
Select name, score from student-1 name = ' Wang Ming '
2, to Wang Ming plus 2 points?
Update Student-1 Set score = score +2 WHERE name = ' Wang Ming '
3, the query is not empty students?
Select from student-1 where memo is not NULL
4. Students who have more than 95 points in the query?
Select from student-1 where score >95
5, Wang Ming transfer, Wang Ming deleted?
Delete from student-1 where name = ' Wang Ming '
6, came a new classmate, named Wang Guonan?
INSERT INTO Student-1
VALUES (20, ' Wang Guonan ', ' 111111111111 ', ' 3 ', ' 95 ', ' running ')
7. Query average score?
Select AVG (score) as average score
From Student-1
8. Query the surname Zhang?
SELECT * FROM Student-1
Where name like ' Zhang% '
9. Use truncate to delete all data
TRUNCATE TABLE Student-1
Write so many examples just hope that everyone ingenious, this case is a student score table to do the demonstration, in exchange for other tables, the syntax is the same, this article is just a basic T-SQL statement, follow-up will continue to update the use of T-SQL statements.
Creation of tables for SQL Server databases with manipulation of data tables using T-SQL statements