ann
          冰是沒有未來的,因為它的永恒
          posts - 107,comments - 34,trackbacks - 0
          postges database
          postges database
          SQL like子句的另一種實現(xiàn)方法,速度比like快      摘要:

          SQL like子句的另一種實現(xiàn)方法,速度比like快


          一般來說使用模糊查詢,大家都會想到LIKE
          select * from table where a like '%字符%'

          如果一個SQL語句中用多個 like模糊查詢,并且記錄條數(shù)很大,那速度一定會很慢。
          下面兩種方法也可實現(xiàn)模糊查詢:
          select * from table where patindex('%字符%',a)>0
          select * from table where charindex('字符',a)>0
          經(jīng)測試這兩種方法比LIKE速度要快。

            閱讀全文
          posted @ 2010-05-04 12:58 冰是沒有未來的,因為它的永恒| 編輯
          pg_restore      摘要: 1.備份表中的數(shù)據(jù)


          D:\Program Files\PostgreSQL-8.3.7\bin\pg_dump.exe -h *.*.*.* -p 5432 -U username -F c -v -f "D:\Program Files\PostgreSQL-8.3.7\bin\sss.backup" -t "\"public\".\"tablename\"" databasename

          2. 創(chuàng)建表

          CREATE TABLE tablename
          (
          id bigint,
          createtime timestamp without time zone,
          modifyname character varying(255),
          modify_date timestamp without time zone,
          modify_detail character varying(100000),
          "name" character varying(255  閱讀全文
          posted @ 2010-03-11 10:02 冰是沒有未來的,因為它的永恒| 編輯
          postgres手冊鏈接      摘要: 一.linux 監(jiān)控數(shù)據(jù)庫活動
          $ ps auxww | grep ^postgres

          postgres 3424 0.0 1.2 42708 26588 ? Ss Jan29 0:00 postgres: writer process
          postgres 3425 0.0 0.0 42576 1284 ? Ss Jan29 0:00 postgres: wal writer process
          postgres 3426 0.0 0.0 43364 1972 ? Ss J  閱讀全文
          posted @ 2010-02-09 15:30 冰是沒有未來的,因為它的永恒| 編輯
          sql 刪除重復的數(shù)據(jù)      摘要: 1、對于第一種重復,比較容易解決,使用

          select distinct * from tableName

            就可以得到無重復記錄的結果集。

             如果該表需要刪除重復的記錄(重復記錄保留1條),可以按以下方法刪除

          select distinct * into #Tmp from tableName
          drop table tableName
          select * into tableName from #Tmp
          drop table #Tmp


            閱讀全文
          posted @ 2010-02-08 16:22 冰是沒有未來的,因為它的永恒| 編輯
          PostgreSQL數(shù)據(jù)庫日常維護兩個要點      摘要:

          數(shù)據(jù)庫服務器,應對是高并發(fā)的訪問,每天都有大量的讀寫刪除操作。因此,時間一長服務器的內存就耗盡,數(shù)據(jù)庫的占的空間也很大。為了應對這個情況,我制定兩個常用的維護操作。

          一、注重日常清理(VACUUM;)。因為有大量的更新(update)"刪除(delete)操作,會有大量的空間需要釋放。

          每日執(zhí)行一次VACUUM,每周訪問量低的時候執(zhí)行VACUUM FULL;

          語法結構;

          VACUUM [ FULL | FREEZE ] [ VERBOSE ] [ table ]
          VACUUM [ FULL | FREEZE ] [ VERBOSE ] ANALYZE [ table [ (column [, ...] ) ] ]

          FULL ------選擇"完全"清理,這樣可以恢復更多的空間, 但是花的時間更多并且在表上施加了排它鎖。
          FREEZE ---------選擇激進的元組"凍結"。
          VERBOSE --------- 為每個表打印一份詳細的清理工作報告。 <  閱讀全文
          posted @ 2010-01-07 15:55 冰是沒有未來的,因為它的永恒| 編輯
          postgres create INDEX      摘要: CREATE INDEX 在指定的表上構造一個名為 index_name 的索引。索引主要用來提高數(shù)據(jù)庫性能。但是如果不恰當?shù)氖褂脤е滦阅艿南陆怠?

          PostgreSQL 為從索引提供 B-tree,R-tree,hash(散列) 和 GiST 索引方法。 B-tree 索引方法是一個 Lehman-Yao 高并發(fā) B-trees 的實 現(xiàn)。R-tree 索引方法用 Guttman 的二次分裂算法實現(xiàn)了標準的 R-trees。 hash(散列)索引方法是 Litwin 的線性散列的一個實現(xiàn)。 用戶也可以定義它們自己的索引方法,但這個工作相當復雜。
          如果出現(xiàn)了 WHERE 子句,則創(chuàng)建一個部分索引。 部分索引是一個只包含表的一部分記錄的索引,通常是該表中比其它部分數(shù)據(jù)更有用的部分。

          在 WHERE 子句里用的表達式只能引用下層表的字段,但是它可以使用所有字段,而不僅僅是被索引的字段。 目前,子查詢和聚集表達式也不能出現(xiàn)在WHERE里。

          索引定義里的所有函數(shù)和操作符都必須是immutable,(不  閱讀全文
          posted @ 2009-12-22 10:00 冰是沒有未來的,因為它的永恒| 編輯
          postgres數(shù)據(jù)庫的操作      摘要: 1. 修改role密碼
          alter role postgres password 'postgres';

          2. 設置postgres遠程連接

          1). 修改listen addresses
          sudo vim /etc/postgresql/8.3/main/pg_hba.conf
          # listen_addresses = 'localhost'
          設置為 listen_addresses = '*'

          2). 添加ip

          sudo vim /etc/postgresql/8.3/main/postgresql.conf
          在 最后一行添加
          host all all 192.168.0.0/16 md5

          3  閱讀全文
          posted @ 2009-07-31 14:23 冰是沒有未來的,因為它的永恒| 編輯
          數(shù)據(jù)庫備份      摘要: 1.備份
          >pg_dump -h 192.168.4.217 --username admin RestaurantCenter >restaurantcenter1.sql

          2.執(zhí)行sql
          >psql -h 192.168.1.18 --username postgres RestaurantCenter < restaurantcenter1.sql

            閱讀全文
          posted @ 2009-07-02 13:43 冰是沒有未來的,因為它的永恒| 編輯
          為已經(jīng)存在的數(shù)據(jù)庫添加GIS功能      摘要: PgAdmin, open up the SQL window by clicking the SQL button (the one with the pencil).
          Choose “File ? Open…” and navigate to

          C:\Program Files\PostgreSQL\8.3\share\contrib\lwpostgis.sql

          Press the “Run” button. (The green triangle.) The lwpostgis.sql file will execute, loading the PostGIS functions and objects into the “postgis” database.

          Choose “File ? Open…” and navigate to

          C:\Program Files\PostgreSQL\8.3\share\contrib\spatial_ref_sys.sql  閱讀全文
          posted @ 2009-06-03 09:55 冰是沒有未來的,因為它的永恒| 編輯

          當下,把心放下 放下如果是可能的,那一定是在當下,
          不在過去,也不在未來。
          當下放下。唯有活在當下,你的問題才能放下。

          主站蜘蛛池模板: 盱眙县| 习水县| 诸暨市| 伊吾县| 大城县| 新干县| 特克斯县| 上林县| 康马县| 六盘水市| 嘉义市| 昭苏县| 铜川市| 牟定县| 枣阳市| 松江区| 高淳县| 富宁县| 延津县| 静安区| 洛扎县| 建宁县| 西藏| 米易县| 明水县| 洛隆县| 巴林左旗| 普兰县| 彰化县| 娄烦县| 大厂| 化隆| 阿拉善左旗| 福贡县| 陇西县| 嘉峪关市| 甘德县| 大港区| 岢岚县| 延吉市| 古田县|