Difference between revisions of "Data type"

From LemonWiki共筆
Jump to navigation Jump to search
Line 98: Line 98:
 
* [http://dev.mysql.com/doc/refman/5.0/en/data-types.html MySQL :: MySQL 5.0 Reference Manual :: 10 Data Types]
 
* [http://dev.mysql.com/doc/refman/5.0/en/data-types.html MySQL :: MySQL 5.0 Reference Manual :: 10 Data Types]
 
* SQL Server 2005 [http://msdn.microsoft.com/en-us/library/ms187594(SQL.90).aspx Data Types (Database Engine)] / [http://msdn.microsoft.com/zh-tw/library/ms187594(v=sql.105).aspx 資料類型 (Database Engine)]
 
* SQL Server 2005 [http://msdn.microsoft.com/en-us/library/ms187594(SQL.90).aspx Data Types (Database Engine)] / [http://msdn.microsoft.com/zh-tw/library/ms187594(v=sql.105).aspx 資料類型 (Database Engine)]
 +
* [http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm Oracle Data Types]
 
* [http://www.databaseanswers.org/data_models/index.htm Industry Data Models]
 
* [http://www.databaseanswers.org/data_models/index.htm Industry Data Models]
  
 
[[Category:Web_Dev]] [[Category:Database]] [[Category:MySQL]]
 
[[Category:Web_Dev]] [[Category:Database]] [[Category:MySQL]]

Revision as of 17:58, 30 August 2013

資料表欄位設計時,不同資料建議採用的資料型態(data type)


Web site design and development process


examples of data and suggested datatype

  • birth year
    • data type: int
    • ex: 1905 ~ 2013
    • range/limit: 108 yeas old[1][2]


  • IP(v4):
    • varchar(15)
    • ex: 255.255.255.255 [3]
    • range/limit:
  • IP range - Classless inter-domain routing (CIDR)[4]
    • 12 or 24 bytes (IPv4 and IPv6 networks)[5]
    • ex: 69.208.0.0/32
  • Chinese name:
    • 最長姓名有13個字 [8]
    • LINE姓名欄位長度限制: 15字(15個中文字或15英文字母)
  • unix timestamp:
    • bigint(10) ;
    • ex: 1328664539
    • range/limit:
  • School ID defined by MOE at Taiwan / 學校代碼[9]
    • integer: 4(university) ~ 6
    • ex: 0001(國立政治大學)、373607(臺北市立華江國小)。前面可能有零。
    • range/limit:
  • 經緯度 (經度,緯度):
    • DECIMAL(18,12)[10] or FLOAT( 10, 6 )[11]
    • ex: 37.401724,-122.114646
    • range/limit:
  • 價錢/金額
    • DECIMAL(10,2)[12]
    • ex:
    • range/limit: 0.00 ~ 99999999.99
  • 台灣縣市欄位值 下拉式選單[13]
$city = array("基隆市", "台北市", "新北市", "桃園縣", "新竹市", "新竹縣", "苗栗縣", "台中市", 
        "彰化縣", "南投縣", "雲林縣", "嘉義市", "嘉義縣", "台南市", "高雄市", "屏東縣", "台東縣", "花蓮縣", 
        "宜蘭縣", "澎湖縣", "金門縣", "連江縣");
  • 密碼
    • varchar 允許最小8個字元長度[14]
 (left blank intentionally)
* data
** data type
** ex:
** range/limit:

comparision of datatypes in different database server

Storing Unicode text[15]

  • MySQL: varchar
  • MS SQL 2008: nvarchar

DATETIME: ex: "2013-06-13 03:33:33"

  • MS SQL 2008, MySQL is equivalent

TIMESTAMP: MS SQL 2008 and MySQL is NOT equivalent[16] Icon_exclaim.gif

  • MS SQL 2008[17] ex: 0x00000000000007D3
  • MySQL ex: 2013-06-13 03:33:33

tools

ER圖(entity-relationship diagram)

references

further reading