Sybase database, normal table modify partition Table step

Source: Internet
Author: User
Tags sybase sybase database

objective of this article: to guide the project side personnel to meet such change requirements, you can refer to the changes themselves.
Requirement: Sybase database, normal table T_jingyu modified to partition table by day partition.

1.sp_help View T_jingyu table structure, index and other information?
1 2 sp_help t_jingyugo
Tip: You can use the Dbartisan tool to extract the original table statement reference directly
2.sp_rename renames the normal table T_jingyu and its primary key Pk_t_jingyu and index idx_t_jingyu_1.
?
1 2 3 4 5 6 sp_rename t_jingyu,t_jingyu_bak go sp_rename "t_jingyu_bak.pk_t_jingyu",pk_t_jingyu_bak go sp_rename "t_jingyu_bak.idx_t_jingyu_1",idx_t_jingyu_1_bakgo
3. After you have determined that there is no problem with the backup above, create the partition table T_jingyu, partition index.
3.1 Creating a partitioned table T_jingyu?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 CREATE TABLE dbo.t_jingyu (     oid         varchar(64)   NOT NULL,     related_rnc varchar(64)   NULL,     start_time  datetime      NOT NULL ) LOCK DATAROWS PARTITION BY RANGE (start_time) (p20140601 VALUES <= (‘2014-06-01 23:59:59.999‘) ON seg_d_wrnop, p20140602 VALUES <= (‘2014-06-02 23:59:59.999‘) ON seg_d_wrnop, p20140603 VALUES <= (‘2014-06-03 23:59:59.999‘) ON seg_d_wrnop, p20140604 VALUES <= (‘2014-06-04 23:59:59.999‘) ON seg_d_wrnop, p20140605 VALUES <= (‘2014-06-05 23:59:59.999‘) ON seg_d_wrnop, p20140606 VALUES <= (‘2014-06-06 23:59:59.999‘) ON seg_d_wrnop, p20140607 VALUES <= (‘2014-06-07 23:59:59.999‘) ON seg_d_wrnop, p20140608 VALUES <= (‘2014-06-08 23:59:59.999‘) ON seg_d_wrnop, p20140609 VALUES <= (‘2014-06-09 23:59:59.999‘) ON seg_d_wrnop, p20140610 VALUES <= (‘2014-06-10 23:59:59.999‘) ON seg_d_wrnop, p20140611 VALUES <= (‘2014-06-11 23:59:59.999‘) ON seg_d_wrnop, p20140612 VALUES <= (‘2014-06-12 23:59:59.999‘) ON seg_d_wrnop, p20140613 VALUES <= (‘2014-06-13 23:59:59.999‘) ON seg_d_wrnop, p20140614 VALUES <= (‘2014-06-14 23:59:59.999‘) ON seg_d_wrnop, p20140615 VALUES <= (‘2014-06-15 23:59:59.999‘) ON seg_d_wrnop, p20140616 VALUES <= (‘2014-06-16 23:59:59.999‘) ON seg_d_wrnop, p20140617 VALUES <= (‘2014-06-17 23:59:59.999‘) ON seg_d_wrnop, p20140618 VALUES <= (‘2014-06-18 23:59:59.999‘) ON seg_d_wrnop, p20140619 VALUES <= (‘2014-06-19 23:59:59.999‘) ON seg_d_wrnop, p20140620 VALUES <= (‘2014-06-20 23:59:59.999‘) ON seg_d_wrnop, p20140621 VALUES <= (‘2014-06-21 23:59:59.999‘) ON seg_d_wrnop, p20140622 VALUES <= (‘2014-06-22 23:59:59.999‘) ON seg_d_wrnop, p20140623 VALUES <= (‘2014-06-23 23:59:59.999‘) ON seg_d_wrnop, p20140624 VALUES <= (‘2014-06-24 23:59:59.999‘) ON seg_d_wrnop, p20140625 VALUES <= (‘2014-06-25 23:59:59.999‘) ON seg_d_wrnop, p20140626 VALUES <= (‘2014-06-26 23:59:59.999‘) ON seg_d_wrnop, p20140627 VALUES <= (‘2014-06-27 23:59:59.999‘) ON seg_d_wrnop, p20140628 VALUES <= (‘2014-06-28 23:59:59.999‘) ON seg_d_wrnop, p20140629 VALUES <= (‘2014-06-29 23:59:59.999‘) ON seg_d_wrnop, p20140630 VALUES <= (‘2014-06-30 23:59:59.999‘) ON seg_d_wrnop) go
3.2 Creating a unique nonclustered partition index (instead of the primary key of the primary table)?
1 2 3) 4 5 CREATE UNIQUE NONCLUSTERED INDEX pk_t_jingyu     ON dbo.t_jingyu(oid,start_time)     ON seg_i_wrnop LOCAL INDEXgo
3.3 Creating additional nonclustered partition indexes?
1 2 3) 4 5 CREATE NONCLUSTERED INDEX idx_t_jingyu_1     ON dbo.t_jingyu(start_time,related_rnc)     ON seg_i_wrnop LOCAL INDEXgo
4. Selectively insert the required data into a new table?
0 S insert into t_jingyu select * from t_jingyu_bak where 条件go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.