Question : How to truncate partitioned table in Sybase?

My table structure is like that.
Create Table T1
(
       a chr(4) not null,
       ............
      .............
)
lock datapages
 on 'Seg1'
go
alter table uw_ri_ac partition 60
go

sp_placeobject 'Seg1', 'dbo.T1'
go

And I issue below command to truncate above partitioned table.
TRUNCATE TABLE T1 partition 'Seg1'
TRUNCATE TABLE T1 partition Seg1

But I get below error
"Syntax error near partition"

What is wrong with the truncate statement?

Thanks.

Answer : How to truncate partitioned table in Sybase?

With just a brief glance, I think there is some confusion about physical placement and partitioning.

When you create the table "on 'Seg1'" you are telling Sybase to store the entire table on the database/device segment you have created called 'Seg1".  You then, further, tell Sybase to create 60 round-robin partitions of the table.

So "Seg1" is not the name of a partition at all; just the name of the database/device segment you put the table on.  I am not in front the doc right now so I am not sure of the naming convention however, you can do an sp_help T1 and it will tell you the partition names which you can then use to selectively truncate.

BTW, with round-robin partitioning, you really have little control over what partition the data winds up on so you probably won't have need to truncate that way.  ASE15 introduces semantic partitioning buy you have to purchase it as an option.

BTW2, making 60 round-robin partitions is probably too many unless you are on a very large (64 core) machine.  Round-robin partitioning is a mechanism to encourage and enhance parallel functionality of the engine; it won't help you keep say 60 days of transaction data, each in it's own partition, and then truncate off the oldest.  For that you need the semantic partitioning option.

Regards,
Bill
Random Solutions  
 
programming4us programming4us