1) 所有的“對象”都在它自己的table中,沒有冗余。非標(biāo)準(zhǔn)化的特點:
2) 數(shù)據(jù)庫通常由E-R圖生成。
3) 簡潔,更新屬性通常只需要更新很少的記錄。
4) Join操作比較耗時。
5) Select,sort優(yōu)化措施比較少。
6) 適用于OLTP應(yīng)用。
1) 在一張表中存儲很多數(shù)據(jù),數(shù)據(jù)冗余。
2) 更新數(shù)據(jù)開銷很大,更新一個屬性可能會更新很多表,很多記錄。
3) 在刪除數(shù)據(jù)是有可能丟失數(shù)據(jù)。
4) Select,order有很多優(yōu)化的選擇。
5) 適用于DSS應(yīng)用。
1) 對OLTP使用標(biāo)準(zhǔn)化,對DSS使用非標(biāo)準(zhǔn)化2.1.2 數(shù)據(jù)類型
2) 使用物化視圖。MySQL不直接支持該數(shù)據(jù)庫特性,但是可以用MyISAM表代替。
3) 冗余一些數(shù)據(jù)在表格中,例如將ref_id和name存在同一張表中。但是要注意更新問題。
4) 對于一些簡單的對象,直接使用value作為建。例如IP address等
5) Reference by PRIMARY/UNIQUE KEY。MySQL可以優(yōu)化這種操作,例如:
java 代碼
- select city_name
- from city,state
- where state_id=state.id and state.code=‘CA’” converted to “select city_name from city where state_id=12
1) 使用正確合適的類型,不要將數(shù)字存儲為字符串。
2) 盡可能地使用最有效(最小)的數(shù)據(jù)類型。MySQL有很多節(jié)省磁盤空間和內(nèi)存的專業(yè)化類型。
3) 盡可能使用較小的整數(shù)類型使表更小。例如,MEDIUMINT經(jīng)常比INT好一些,因為MEDIUMINT列使用的空間要少25%。
4) 如果可能,聲明列為NOT NULL。它使任何事情更快而且每列可以節(jié)省一位。注意如果在應(yīng)用程序中確實需要NULL,應(yīng)該毫無疑問使用它,只是避免 默認(rèn)地在所有列上有它。
5) 對于MyISAM表,如果沒有任何變長列(VARCHAR、TEXT或BLOB列),使用固定尺寸的記錄格式。這比較快但是不幸地可能會浪費一些空間。即使你已經(jīng)用CREATE選項讓VARCHAR列ROW_FORMAT=fixed,也可以提示想使用固定長度的行。
6) 使用sample character set,例如latin1。盡量少使用utf-8,因為utf-8占用的空間是latin1的3倍。可以在不需要使用utf-8的字段上面使用latin1,例如mail,url等。
1) MySQL只會使用前綴,例如key(a, b) …where b=5 將使用不到索引。2.2 Designing queries
2) 要選擇性的使用索引。在變化很少的列上使用索引并不是很好,例如性別列。
3) 在Unique列上定義Unique index。
4) 避免建立使用不到的索引。
5) 在Btree index中(InnoDB使用Btree),可以在需要排序的列上建立索引。
6) 避免重復(fù)的索引。
7) 避免在已有索引的前綴上建立索引。例如:如果存在index(a,b)則去掉index(a)。
8) 控制單個索引的長度。使用key(name(8))在數(shù)據(jù)的前面幾個字符建立索引。
9) 越是短的鍵值越好,最好使用integer。
10) 在查詢中要使用到索引(使用explain查看),可以減少讀磁盤的次數(shù),加速讀取數(shù)據(jù)。
11) 相近的鍵值比隨機好。Auto_increment就比uuid好。
12) Optimize table可以壓縮和排序index,注意不要頻繁運行。
13) Analyze table可以更新數(shù)據(jù)。
1) 在有index的情況下,盡量保證查詢使用了正確的index。可以使用EXPLAIN select …查看結(jié)果,分析查詢。3. 服務(wù)器端優(yōu)化
2) 查詢時使用匹配的類型。例如select * from a where id=5, 如果這里id是字符類型,同時有index,這條查詢則使用不到index,會做全表掃描,速度會很慢。正確的應(yīng)該是 … where id=”5” ,加上引號表明類型是字符。
3) 使用--log-slow-queries –long-query-time=2查看查詢比較慢的語句。然后使用explain分析查詢,做出優(yōu)化。
--character-set:如果是單一語言使用簡單的character set例如latin1。盡量少用Utf-8,utf-8占用空間較多。4. 存儲引擎優(yōu)化
--memlock:鎖定MySQL只能運行在內(nèi)存中,避免swapping,但是如果內(nèi)存不夠時有可能出現(xiàn)錯誤。
--max_allowed_packet:要足夠大,以適應(yīng)比較大的SQL查詢,對性能沒有太大影響,主要是避免出現(xiàn)packet錯誤。
--max_connections:server允許的最大連接。太大的話會出現(xiàn)out of memory。
--table_cache:MySQL在同一時間保持打開的table的數(shù)量。打開table開銷比較大。一般設(shè)置為512。
--query_cache_size: 用于緩存查詢的內(nèi)存大小。
--datadir:mysql存放數(shù)據(jù)的根目錄,和安裝文件分開在不同的磁盤可以提高一點性能。
1) 不支持事務(wù),宕機會破壞表4.1.1.2 Typical MyISAM usages
2) 使用較小的內(nèi)存和磁盤空間
3) 基于表的鎖,并發(fā)更新數(shù)據(jù)會出現(xiàn)嚴(yán)重性能問題
4) MySQL只緩存Index,數(shù)據(jù)由OS緩存
1) 日志系統(tǒng)4.1.2 MyISAM優(yōu)化要點
2) 只讀或者絕大部分是讀操作的應(yīng)用
3) 全表掃描
4) 批量導(dǎo)入數(shù)據(jù)
5) 沒有事務(wù)的低并發(fā)讀/寫
1) 聲明列為NOT NULL,可以減少磁盤存儲。4.1.3 MyISAM Table Locks
2) 使用optimize table做碎片整理,回收空閑空間。注意僅僅在非常大的數(shù)據(jù)變化后運行。
3) Deleting/updating/adding大量數(shù)據(jù)的時候禁止使用index。使用ALTER TABLE t DISABLE KEYS。
4) 設(shè)置myisam_max_[extra]_sort_file_size足夠大,可以顯著提高repair table的速度。
1) 避免并發(fā)insert,update。4.1.4 MyISAM Key Cache
2) 可以使用insert delayed,但是有可能丟失數(shù)據(jù)。
3) 優(yōu)化查詢語句。
4) 水平分區(qū)。
5) 垂直分區(qū)。
6) 如果都不起作用,使用InnoDB。
1) 設(shè)置key_buffer_size variable。MyISAN最主要的cache設(shè)置,用于緩存MyISAM表格的index數(shù)據(jù),該參數(shù)只對MyISAM有影響。通常在只使用MyISAM的Server中設(shè)置25-33%的內(nèi)存大小。
2) 可以使用幾個不同的Key Caches(對一些hot data)。
a) SET GLOBAL test.key_buffer_size=512*1024;2) Preload index到Cache中可以提高查詢速度。因為preloading index是順序的,所以非常快。
b) CACHE INDEX t1.i1, t2.i1, t3 IN test;
a) LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
1) 支持事務(wù),ACID,外鍵。4.2.1.2 InnoDB Good For
2) Row level locks。
3) 支持不同的隔離級別。
4) 和MyISAM相比需要較多的內(nèi)存和磁盤空間。
5) 沒有鍵壓縮。
6) 數(shù)據(jù)和索引都緩存在內(nèi)存hash表中。
1) 需要事務(wù)的應(yīng)用。4.2.2 InnoDB優(yōu)化要點
2) 高并發(fā)的應(yīng)用。
3) 自動恢復(fù)。
4) 較快速的基于主鍵的操作。
1) 盡量使用short,integer的主鍵。4.2.3 InnoDB服務(wù)器端設(shè)定
2) Load/Insert數(shù)據(jù)時按主鍵順序。如果數(shù)據(jù)沒有按主鍵排序,先排序然后再進行數(shù)據(jù)庫操作。
3) 在Load數(shù)據(jù)是為設(shè)置SET UNIQUE_CHECKS=0,SET FOREIGN_KEY_CHECKS=0,可以避免外鍵和唯一性約束檢查的開銷。
4) 使用prefix keys。因為InnoDB沒有key壓縮功能。
innodb_buffer_pool_size:這是InnoDB最重要的設(shè)置,對InnoDB性能有決定性的影響。默認(rèn)的設(shè)置只有8M,所以默認(rèn)的數(shù)據(jù)庫設(shè)置下面InnoDB性能很差。在只有InnoDB存儲引擎的數(shù)據(jù)庫服務(wù)器上面,可以設(shè)置60-80%的內(nèi)存。更精確一點,在內(nèi)存容量允許的情況下面設(shè)置比InnoDB tablespaces大10%的內(nèi)存大小。5. 緩存
innodb_data_file_path:指定表數(shù)據(jù)和索引存儲的空間,可以是一個或者多個文件。最后一個數(shù)據(jù)文件必須是自動擴充的,也只有最后一個文件允許自動擴充。這樣,當(dāng)空間用完后,自動擴充數(shù)據(jù)文件就會自動增長(以8MB為單位)以容納額外的數(shù)據(jù)。例如: innodb_data_file_path=/disk1/ibdata1:900M;/disk2/ibdata2:50M:autoextend兩個數(shù)據(jù)文件放在不同的磁盤上。數(shù)據(jù)首先放在ibdata1中,當(dāng)達到900M以后,數(shù)據(jù)就放在ibdata2中。一旦達到50MB,ibdata2將以8MB為單位自動增長。如果磁盤滿了,需要在另外的磁盤上面增加一個數(shù)據(jù)文件。
innodb_data_home_dir:放置表空間數(shù)據(jù)的目錄,默認(rèn)在mysql的數(shù)據(jù)目錄,設(shè)置到和MySQL安裝文件不同的分區(qū)可以提高性能。
innodb_log_file_size:該參數(shù)決定了recovery speed。太大的話recovery就會比較慢,太小了影響查詢性能,一般取256M可以兼顧性能和recovery的速度
。
innodb_log_buffer_size:磁盤速度是很慢的,直接將log寫道磁盤會影響InnoDB的性能,該參數(shù)設(shè)定了log buffer的大小,一般4M。如果有大的blob操作,可以適當(dāng)增大。
innodb_flush_logs_at_trx_commit=2: 該參數(shù)設(shè)定了事務(wù)提交時內(nèi)存中l(wèi)og信息的處理。
1) =1時,在每個事務(wù)提交時,日志緩沖被寫到日志文件,對日志文件做到磁盤操作的刷新。Truly ACID。速度慢。innodb_file_per_table:可以存儲每個InnoDB表和它的索引在它自己的文件中。
2) =2時,在每個事務(wù)提交時,日志緩沖被寫到文件,但不對日志文件做到磁盤操作的刷新。只有操作系統(tǒng)崩潰或掉電才會刪除最后一秒的事務(wù),不然不會丟失事務(wù)。
3) =0時, 日志緩沖每秒一次地被寫到日志文件,并且對日志文件做到磁盤操作的刷新。任何mysqld進程的崩潰會刪除崩潰前最后一秒的事務(wù)
transaction-isolation=READ-COMITTED: 如果應(yīng)用程序可以運行在READ-COMMITED隔離級別,做此設(shè)定會有一定的性能提升。
innodb_flush_method: 設(shè)置InnoDB同步IO的方式:
1) Default – 使用fsync()。innodb_thread_concurrency: InnoDB kernel最大的線程數(shù)。
2) O_SYNC 以sync模式打開文件,通常比較慢。
3) O_DIRECT,在Linux上使用Direct IO。可以顯著提高速度,特別是在RAID系統(tǒng)上。避免額外的數(shù)據(jù)復(fù)制和double buffering(mysql buffering 和OS buffering)。
1) 最少設(shè)置為(num_disks+num_cpus)*2。
2) 可以通過設(shè)置成1000來禁止這個限制
www.bitsCN.com
qt4 開源版本qt-win-opensource-src-4.3.3
qt官方網(wǎng)站 http://trolltech.com/
解壓qt4。
使用Visual Studio 2008 Command Prompt到命令行模式。
到qt目錄下
cd bin
configure (很久)
namke (很久)
建立項目
編輯一個xx.cpp文件
在文件目錄下執(zhí)行
qmake -project
qmake -t vcapp
下面用一個小程序測試一下
創(chuàng)建文件名為hello.cpp,輸入如下代碼:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World!");
label->show();
return app.exec();
}
然后
prompt> qmake -project -o hello.pro
prompt> qmake
prompt> nmake
就會在debug文件夾下生成一個.exe文件。
qmake
用vs2008打開項目
編輯ui
執(zhí)行bin目錄下的designer.exe
存盤,
uic -o xxx.h xxx.ui
復(fù)制到項目下面
執(zhí)行qmake
用vs2008打開
字符串使用gbk編碼(全局)
main函數(shù)加入
QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK"));.
YOUR_LIB=your_path
for jar in `ls $YOUR_LIB/*.jar`
do
CLASSPATH="$CLASSPATH:""$jar"
done
windows :
SETLOCAL ENABLEDELAYEDEXPANSION
set LIB=xx
set CLASSPATH=.
FOR %%C IN (LIB\*.jar) DO set CLASSPATH=!CLASSPATH!;%%C
echo %CLASSPATH%
unix ksh:
暫無
?
1.4.2jdk編譯執(zhí)行。長時間執(zhí)行沒有發(fā)現(xiàn)有網(wǎng)上所說的由于jit優(yōu)化導(dǎo)致的當(dāng)分配完Foo的內(nèi)存,F(xiàn)oo構(gòu)造函數(shù)未初始化完成就將其地址賦值給foo的錯誤。相信這時候jit已經(jīng)對代碼進行了優(yōu)化。
國外網(wǎng)址關(guān)于Double-Checked Locking的文章http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
Paul Jakubik found an example of a use of double-checked locking that did not work correctly. A slightly cleaned up version of that code is available here.
When run on a system using the Symantec JIT, it doesn't work. In particular, the Symantec JIT compiles
singletons[i].reference = new Singleton();
to the following (note that the Symantec JIT using a handle-based object allocation system).
0206106A mov eax,0F97E78h 0206106F call 01F6B210 ; allocate space for ; Singleton, return result in eax 02061074 mov dword ptr [ebp],eax ; EBP is &singletons[i].reference ; store the unconstructed object here. 02061077 mov ecx,dword ptr [eax] ; dereference the handle to ; get the raw pointer 02061079 mov dword ptr [ecx],100h ; Next 4 lines are 0206107F mov dword ptr [ecx+4],200h ; Singleton's inlined constructor 02061086 mov dword ptr [ecx+8],400h 0206108D mov dword ptr [ecx+0Ch],0F84030h
As you can see, the assignment to singletons[i].reference is performed before the constructor for Singleton is called. This is completely legal under the existing Java memory model, and also legal in C and C++ (since neither of them have a memory model).
上面是國外網(wǎng)站給出的jit代碼和說明。
我機器的內(nèi)存是1.5g,平時一般只用500-700m.如果開機狀態(tài)下,人離開比較久(1-2小時),那個垃圾的策略無視將近1g的空閑內(nèi)存,把東西寫到虛擬內(nèi)存(硬盤)了.所以每次重新操作機器的時候,都要忍受那硬盤的咔噠聲.如果把虛擬內(nèi)存禁了,就沒這現(xiàn)象了,但是我有的時候又會用超過1.5g的內(nèi)存所以不得不開虛擬內(nèi)存.
一、內(nèi)部函數(shù)
1、內(nèi)部合計函數(shù)
1)COUNT(*) 返回行數(shù)
2)COUNT(DISTINCT COLNAME) 返回指定列中唯一值的個數(shù)
3)SUM(COLNAME/EXPRESSION) 返回指定列或表達式的數(shù)值和;
4)SUM(DISTINCT COLNAME) 返回指定列中唯一值的和
5)AVG(COLNAME/EXPRESSION) 返回指定列或表達式中的數(shù)值平均值
6)AVG(DISTINCT COLNAME) 返回指定列中唯一值的平均值
7)MIN(COLNAME/EXPRESSION) 返回指定列或表達式中的數(shù)值最小值
8)MAX(COLNAME/EXPRESSION) 返回指定列或表達式中的數(shù)值最大值
2、日期與時間函數(shù)
1)DAY(DATE/DATETIME EXPRESSION) 返回指定表達式中的當(dāng)月幾號
2)MONTH(DATE/DATETIME EXPRESSION) 返回指定表達式中的月份
3)YEAR(DATE/DATETIME EXPRESSION) 返回指定表達式中的年份
4)WEEKDAY(DATE/DATETIME EXPRESSION) 返回指定表達式中的當(dāng)周星期幾
5)DATE(NOT DATE EXPRESSION) 返回指定表達式代表的日期值
6)TODAY 返回當(dāng)前日期的日期值
7)CURRENT[first to last] 返回當(dāng)前日期的日期時間值
8)COLNAME/EXPRESSION UNITS PRECISION 返回指定精度的指定單位數(shù)
9)MDY(MONTH,DAY,YEAR) 返回標(biāo)識指定年、月、日的日期值
10)DATETIME(DATE/DATETIME EXPRESSION)FIRST TO LAST 返回表達式代表的日期時間值
11)INTERVAL(DATE/DATETIME EXPRESSION)FIRST TO LAST 返回表達式代表的時間間隔值
12)EXTEND(DATE/DATETIME EXPRESSION,[first to last])返回經(jīng)過調(diào)整的日期或日期時間
值
例子1、和UNITS合用,指定日期或時間單位(year,month,day,hour,minute,seond,fraction):
let tmp_date = today + 3 UNITS day
例子2、let tmp_date = MDY(10,30,2002) -- 2002-10-30
例子3、let tmp_date = today + interval(7) day to day --當(dāng)前時間加上7天;
注:該功能與1相似;
例子4、EXTEND轉(zhuǎn)換日期或日期時間值
let tmp_inthour = extend(datetime1,hour to hour)
3、代數(shù)函數(shù)
1)ABS(COLNAME/EXPRESSION): 取絕對值
2)MOD(COLNAME/EXPRESSION,DIVISOR) 返回除以除數(shù)后的模(余數(shù))
3)POW(COLNAME/EXPRESSION,EXPONENT) 返回一個值的指數(shù)冥
例子:let tmp_float = pow(2,3) --8.00000000
4)ROOT(COLNAME/EXPRESSION,[index]) 返回指定列或表達式的根值
5)SQRT(COLNAME/EXPRESSION) 返回指定列或表達式的平方根值
6)ROUND(COLNAME/EXPRESSION,[factor]) 返回指定列或表達式的圓整化值
7)TRUNC(COLNAME/EXPRESSION,[factor]) 返回指定列或表達式的截尾值
說明:上兩者中FACTOR指定小數(shù)位數(shù),若不指定,則為0;若為負(fù)數(shù),則整化到小數(shù)點左邊;
注:ROUND是在指定位上進行4舍5入;TRUNC是在指定位上直接截斷;
let tmp_float = round(4.555,2) --4.56
let tmp_float = trunc(4.555,2) --4.55
4、指數(shù)與對數(shù)函數(shù)
1)EXP(COLNAME/EXPRESSION) 返回指定列或表達式的指數(shù)值
2)LOGN(COLNAME/EXPRESSION) 返回指定列或表達式的自然對數(shù)值
3)LOG10(COLNAME/EXPRESSION) 返回指定列或表達式的底數(shù)位10的對數(shù)值
5、三角函數(shù)
1)COS(RADIAN EXPRESSION) 返回指定弧度表達式的余弦值
2)SIN(RADIAN EXPRESSION) 正弦
3)TAN(RADIAN EXPRESSION) 正切
4)ACOS(RADIAN EXPRESSION) 反余弦
5)ASIN(RADIAN EXPRESSION) 反正弦
6)ATAN(RADIAN EXPRESSION) 反正切
7)ATAN2(X,Y) 返回坐標(biāo)(X,Y)的極坐標(biāo)角度組件
6、統(tǒng)計函數(shù)
1)RANGE(COLNAME) 返回指定列的最大值與最小值之差 = MAX(COLNAME)-MIN
(COLNAME)
2)VARIANCE(COLNAME) 返回指定列的樣本方差;
3)STDEV(COLNAME) 返回指定列的標(biāo)準(zhǔn)偏差;
7、其他函數(shù)
1)USER 返回當(dāng)前用戶名
2)HEX(COLNAME/EXPRESSION) 返回指定列或表達式的十六進制值
3)LENGTH(COLNAME/EXPRESSION) 返回指定字符列或表達式的長度
4)TRIM(COLNAME/EXPRESSION) 刪除指定列或表達式前后的字符
5)COLNAME/EXPRESSION || COLNAME/EXPRESSION 返回并在一起的字符;
二、IDS內(nèi)部函數(shù)
1、DBSERVERNAME 返回數(shù)據(jù)庫服務(wù)器名 let tmp_char=DBSERVERNAME
2、SITENAME 返回數(shù)據(jù)庫服務(wù)器名 let tmp_char=SITENAME
說明:兩者功能相同;
3、DBINFO(‘SPECIAL_KEYWORD') 返回只關(guān)鍵字值
例子1:返回數(shù)據(jù)中每個表的DBSPACE名稱
select dbinfo('dbspace',partnum),tabname from systables
where tabid>99 and tabtype='T' (OK)
例子2:返回任何表中插入的最后一個SERIAL值
select dbinfo('sqlca.sqlerrd1') from systables where tabid = 1
例子3:返回最后一個SELECT,INSERT,UPDATE,DELETE或EXECUTE PROCEDURE語句處理的行數(shù);
select dbinfo('sqlca.sqlerrd2') from systables where tabid=1;
?
One of the more difficult concepts in Informix's handling of date and time values concerns the use of the variables in arithmetic or relational expressions. You can add or subtract DATE and DATETIME variables from each other. You can add or subtract an INTERVAL to a DATE or DATETIME. Table 1 shows the results of different types of operations on DATE and DATETIME values.
Table 1. Operations on DATE and DATETIME Variables
First Operand |
Operation |
Second Operand |
Result |
DATE |
- |
DATETIME |
INTERVAL |
DATETIME |
- |
DATE |
INTERVAL |
DATE |
+- |
INTERVAL |
DATETIME |
DATETIME |
- |
DATETIME |
INTERVAL |
DATETIME |
+- |
INTERVAL |
DATETIME |
INTERVAL |
+ |
DATETIME |
DATETIME |
INTERVAL |
+- |
INTERVAL |
INTERVAL |
DATETIME |
- |
CURRENT |
INTERVAL |
CURRENT |
- |
DATETIME |
INTERVAL |
INTERVAL |
+ |
CURRENT |
DATETIME |
CURRENT |
+- |
INTERVAL |
DATETIME |
DATETIME |
+- |
UNITS |
DATETIME |
INTERVAL |
+- |
UNITS |
INTERVAL |
INTERVAL |
*/ |
NUMBER |
INTERVAL |
Notice that it's always okay to subtract one DATE or DATETIME value from another, as shown here: In such a case, the result is always an INTERVAL variable. It would make no sense to add two DATE or DATETIME values together. What could such an addition represent? When working with INTERVAL values, sometimes it is necessary to specify the precision with which you are dealing. For example, suppose you have the following field defined: To add 10 days to the lead time you could use a SQL statement like this: You could achieve the same results using the UNITS keyword: Like most other programming languages, SQL often allows you to achieve the same ends with different statements. Sometimes the choice is one of personal style. Other times, one format fits in better with a structured style of code writing than another format does. There are several built-in functions that affect date and time calculations. They can apply to either DATE or DATETIME values, with some exceptions. The TODAY function returns a DATE data value representing the current date. For example, you could execute a SQL function like this: The CURRENT function is similar to the TODAY function, except it returns a DATETIME value. Without specific qualifiers, the default is YEAR to FRACTION(3). You can change the precision by using the same YEAR to FRACTION qualifiers as you use for DATETIMES. Thus, this would be legal: The DATE function takes as input a non-DATE value such as CHAR, DATETIME, or INTEGER and returns the corresponding DATE value. For example, the following SQL translates a CHARACTER value to a DATE: This function returns an integer representing the day of the month. Here's an example: This performs like the DAY function except it returns an integer between 1 and 12 representing the month: This returns an integer representing the day of the week, with 0 being Sunday and 6 being Saturday: This function is like the ones above, only it returns a four-digit integer representing the year. This function allows you to use different precisions in a DATETIME than you have specified in the declaration of the variable. It uses the same FIRST to LAST syntax as the DATETIME variables. This function is used to adjust the precision of a DATETIME variable to match the precision of an INTERVAL that you are using in a calculation. If the INTERVAL value has fields that are not part of the DATETIME value that you are using in a calculation, use the EXTEND function to adjust the precision of the DATETIME. EXTEND can either increase or decrease the precision of a DATETIME, depending upon the FIRST and LAST values. Suppose myvariable is declared as DATETIME YEAR to DAY. If you want to add or subtract an INTERVAL defined as MINUTE, you first have to extend the DATETIME as follows: The resulting value will be DATETIME YEAR to MINUTE. The MDY function converts three-integer values into a DATE format. The first integer is the month and must evaluate to an integer in the range 1–12. The second integer is the day and must evaluate to a number in the range from 1 to however many days are in the particular month (28–31). The third expression is the year and must be a four-digit integer. Thus, the following MDY functions would each be valid: returns a DATE of "07/01/50" returns a DATE equal to the first day of the current month in the current year Informix has extensive capabilities for manipulating dates and times, which can make for long and complex SQL statements. Using the three time-related data types and the time-related functions and keywords, you can accomplish almost any type of manipulation of time data. Unfortunately, getting there may be cryptic and painful. If you regularly do extensive date and time manipulation, you should understand all of the intricacies of these data structures.
Have fun!?CURRENT - "07/01/1950" = INTERVAL (my age)
"12/25/2000" – CURRENT = INTERVAL (how long till Xmas?)
UNITS Keyword
lead_time INTERVAL DAY to DAY
SELECT lead_time + INTERVAL(10) DAY to DAY
FROM orders
SELECT lead_time + 10 UNITS DAY
FROM orders
Functions
TODAY
UPDATE member SET change_date = TODAY
WHER member_number = 12345
CURRENT
SELECT * from member
WHERE elapsed_time < CURRENT YEAR to DAY
DATE
SELECT * from member
WHERE enrollment_date > DATE('01/01/99')
DAY
SELECT * from member
WHERE DAY(enrollment_date) > DAY(CURRENT)
MONTH
SELECT * from member
WHERE enrollment_date > MONTH('01/01/99')
WEEKDAY
SELECT * from member
WHERE WEEKDAY(enrollment_date) > WEEKDAY(CURRENT)
YEAR
EXTEND
SELECT EXTEND(myvariable, YEAR to MINUTE) –
INTERVAL(5) MINUTE to MINUTE
FROM member
MDY
MDY(7,1,1950)
MDY(MONTH(TODAY), 1, YEAR(TODAY))
?