軟件測試SQL2000里的數據類型(3)

發表于:2011-07-14來源:未知作者:領測軟件測試網采編點擊數: 標簽:
2.當然兩個表格相互比較的欄位,其資料形態必須相同。 3.一個復雜的查詢其動用到的表格可能會很多個。 整合性的查詢: SELECT COUNT (*) FROM table_name WHER

  2.當然兩個表格相互比較的欄位,其資料形態必須相同。

  3.一個復雜的查詢其動用到的表格可能會很多個。

  整合性的查詢:

  SELECT COUNT (*)

  FROM table_name

  WHERE column_name = xxx

  說明:

  查詢符合條件的資料共有幾筆。

  SELECT SUM(column1)

  FROM table_name

  說明:

  1.計算出總和,所選的欄位必須是可數的數字形態。

  2.除此以外還有 AVG() 是計算平均、MAX()、MIN()計算最大最小值的整合性查詢。

  SELECT column1,AVG(column2)

  FROM table_name

  GROUP BY column1

  HAVING AVG(column2) > xxx

  說明:

  1.GROUP BY: 以column1 為一組計算 column2 的平均值必須和 AVG、SUM等整合性查詢的關鍵字

  一起使用。

  2.HAVING : 必須和 GROUP BY 一起使用作為整合性的限制。

  復合性的查詢

  SELECT *

  FROM table_name1

  WHERE EXISTS (

  SELECT *

  FROM table_name2

  WHERE conditions )

  說明:

  1.WHERE 的 conditions 可以是另外一個的 query。

  2.EXISTS 在此是指存在與否。

  SELECT *

  FROM table_name1

  WHERE column1 IN (

  SELECT column1

  FROM table_name2

  WHERE conditions )

  說明:

  1. IN 後面接的是一個集合,表示column1 存在集合里面。

  2. SELECT 出來的資料形態必須符合 column1。

  其他查詢

  SELECT *

  FROM table_name1

  WHERE column1 LIKE 'x%'

  說明:LIKE 必須和後面的'x%' 相呼應表示以 x為開頭的字串。

  SELECT *

  FROM table_name1

  WHERE column1 IN ('xxx','yyy',..)

  說明:IN 後面接的是一個集合,表示column1 存在集合里面。

  SELECT *

  FROM table_name1

  WHERE column1 BETWEEN xx AND yy

  說明:BETWEEN 表示 column1 的值介於 xx 和 yy 之間。

  3、更改資料:

  UPDATE table_name

  SET column1='xxx'

  WHERE conditoins

  說明:

  1.更改某個欄位設定其值為'xxx'。

  2.conditions 是所要符合的條件、若沒有 WHERE 則整個 table 的那個欄位都會全部被更改。

  4、刪除資料:

  DELETE FROM table_name

  WHERE conditions

  說明:刪除符合條件的資料。

  說明:關于WHERE條件后面如果包含有日期的比較,不同數據庫有不同的表達式。具體如下:

  (1)如果是ACCESS數據庫,則為:WHERE mydate>#2000-01-01#

  (2)如果是ORACLE數據庫,則為:WHERE mydate>cast('2000-01-01' as date)

  或:WHERE mydate>to_date('2000-01-01','yyyy-mm-dd')

  在Delphi中寫成:

  thedate= '2000-01-01';

  query1.SQL.add('select * from abc where mydate>cast('+''''+thedate+''''+' as date)');

  SQL Server 2000 Datatypes

  By Sergey Vartanyan

  Introduction

  Binary datatypes

  Character datatypes

  Date and Time datatypes

  Numeric datatypes

  Integer datatypes

  Monetary datatypes

  Special datatypes

  Text and image datatypes

  Unicode Character datatypes

  User-Defined datatypes

  Introduction

  There are three new datatypes in SQL Server 2000 in comparison with SQL Server 7.0.

  These datatypes were added:

  bigint

  sql_variant

  table

  In this article, I want to tell you about built-in SQL Server 2000 datatypes, about user-defined datatypes and what datatype is generally used in a particular situation.

  Binary datatypes

  Binary data is similar to hexadecimal data and consists of the characters 0 through 9 and A through F, in groups of two characters each. You should specify 0x before binary value when input it.

  There are two binary datatypes:

  binary[(n)]

  varbinary[(n)]

  Binary[(n)] datatype can store up to 8000 bytes of fixed-length binary data. You can specify the maximum byte length with n.

  Varbinary[(n)] datatype can store up to 8000 bytes of variable-length binary data. You can specify the maximum byte length with n. Variable-length means that binary data can contain less than n bytes, and the storage size will be the actual length of the data entered.

  You should use varbinary datatype instead of binary datatype, when you expect null values or a variation in data size.

  Character datatypes

  Character datatypes are used to store any combination of letters, symbols, and numbers. You should enclose character data with quotation marks, when enter it.

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97