首页 > 编程知识 正文

oracle怎么建索引,oracle如何删除索引

时间:2023-05-06 08:50:38 阅读:110663 作者:4218

Oracle索引和Postgresql索引1、Oracle索引1.1的创建语法:

createuniuqe|bitmapindexschema.index _ nameonschema.table _ name|column _ name|expression ASC|desc, column _ name . tablespace tablespace _ namestoragestorage _ settings logging|nologgingcomputestaticsnocompress|compace

1 ) unique|bitmap :指定unique作为唯一的值索引,bitmap作为位图索引,省略B-Tree索引。

2 ) column _ name|desc )连接多列的索引,对于expression,为基于函数的索引

3 ) TABLESPACE )指定存储索引的表空间(如果索引和原始表不在一个表空间中,则效率较高) ) ) ) )。

4 ) STORAGE )可以进一步设置表空间的存储参数

5 ) LOGGING | NOLOGGING :是否在索引中创建重做日志(对于超级战斗机,尽量使用NOLOGGING减少占用空间,提高效率) )。

6 ) COMPUTE STATISTICS :在创建新索引时收集统计信息

7 ) NOCOMPRESS | COMPRESS :是否使用“密钥压缩”(密钥压缩可以删除一个密钥列中出现的重复值)。)

8 ) NOSORT | REVERSE:NOSORT表示按与表相同的顺序编制索引,REVERSE表示按相反的顺序存储索引值

9 ) PARTITION | NOPARTITION :可以使用分区表和未分区表对创建的索引进行分区

1.2索引类型

b树索引位图索引散列索引组织表

反转基于密钥索引函数的索引分区索引的本地和全局索引

b树索引- -单列索引createindexindx _ on _ dep _ idone MP (dep _ id ); - createindexindx _ EMP _ name _ salaryonemp (EMP _ name,salary ) COMPRESS 1; -- NOLOGGING模式,加快速度,节约时间,减少日志记录量createindexindx _ on _ dep _ id _ noon EMP (dep _ id ) NOSORT NOLOGGING; -- Cluster Index表簇索引createclusterpersonnel (department number (4); createindexidx _ personnelonclusterpersonnel; - -索引到-- XMLType类型表的createtablexwarehouses (warehouse _ id number, warehouse _ spec xmltype xmltype warehouse _ specstoreascloore位图索引createbitmapindexindx _ on _ leadidonemp (lead ) 分区索引的唯一索引createuniqueindexindx _ on _ EMP _ nameonemp (EMP _ EMP )。索引createindexindx _ dep _ EMP ) 基于函数的索引createindexindx _ upperonemp (upper (EMP _ name ) ); 分区索引- -范围--partitionedglobalindexcreateindexcost _ ixon EMP (salary ) globalpartitionbyrange (salary ) partition - hash-partitionedglobalindexcreateindexsalary _ ixon EMP (salary ) globalpartitionbyhash ) salary ) PARTITIONS 4; 本地和本地

全局索引:可以分割分区,也可以不分割。 这意味着您可以创建范围分区或散列分区,并在分区表或非分区表中创建。 这意味着全局索引是完全独立的,需要做更多的维护工作。

本地索引(local index )的分区格式与表的分区格式完全相同,从属列相同,存储属性也相同。 对于本地索引,索引分区维护将自动进行。 这意味着在为add/drop/split/truncate表创建分区时,本地索引会自动维护索引分区。 二. Postgresql索引1.1语法

create [ unique ] index [ concurrently ] [ [ if not exists ] name ] on table _ name [ using method ] { column _ name|()

PostgreSQL提供了几种索引类型: B-树、散列、GIST、SP-GiST和GIN。 对不同的索引类型使用不同的算法非常适合不同类型的查询。 缺省情况下,CREATE INDEX命令会为最常见的情况创建B-tree索引。

b树--createindexindx _ on _ dep _ idone MP (dep _ id ); -组合createindexindx _ EMP _ name _ salaryonemp (EMP _ name,salary )索引(压缩); ginindexcreateindexgin _ idxondocuments _ tableusinggin (locations ) with(fastupdate=off );

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。