程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> SQL語言備忘錄

SQL語言備忘錄

編輯:關於SqlServer
Boolean Data
BOOLEAN   TURE/FALSE
Numeric Data
Exact Numbers
INTEGER (INT,INT4) 2,147,483,648 to 2,147,483,647
SMALLINT -32768 to 32767
BIGINT (INT8) 8位整數
Approximate Numbers
FLOAT[precision]
REAL
DOUBLE PRECISION
Formatted Numbers
DECIMAL(i,j), DEC(i,j) or NUMERIC(i,j)
 
CREATE TABLE TT (A DATE, B DATE, C INTERVAL); (creat 錯)
INSERT INTO TT(A, C) VALUES(NOW(),'1 DAY');
UPDATE TT SET B = A+ '2 MONTH'::INTERVAL;
 
‘2000-02-29’ 推薦   to_date('2000/02/29' , ‘yyyy/mm/dd' )
 
CREATE DOMAIN hour_dom AS INTEGER DEFAULT 0 CHECK (VALUE >= 0);
CREATE DOMAIN genderDom AS CHAR   DEFAULT ‘M’
       CHECK (VALUE IN (‘F’, ‘f’,‘M’ ,‘m’));  
 
CREATE TABLE BOOK
 (  Book_Id NUMERIC(6) NOT NULL,
       Edition NUMERIC(3) NOT NULL,
       CallNumber VARCHAR(8) NOT NULL UNQUE,( UNQUE 備選碼    唯一碼)
       Primary Key (Book_Id),
       FOREIGN KEY (LibCheck) REFERENCES LIBRARIAN(SSN)
 );
 
DROP TABLE MEMBER CASCADE;
DROP TABLE MEMBER RESTRICT;
 
ALTER TABLE tableName
[ADD [COLUMN] columnName dataType [NOT NULL] [UNIQUE]
[DEFAULT defaultOption] [CHECK (searchCondition)]]
[DROP [COLUMN] columnName [ RESTRICT | CASCADE ]]
[ADD [CONSTRAINT [constraintName]]tableConstraintDefinition]
[DROP CONSTRAINT constraintName [ RESTRICT | CASCADE ]]
[ALTER [COLUMN] SET DEFAULT defaultOption]
[ALTER [COLUMN] DROP DEFAULT]
 
第一:
ALTER TABLE products ADD COLUMN description text ;
ALTER TABLE products DROP COLUMN description RESTRICT;
ALTER TA
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved