alter table

Use alter table to:

The following partial syntax for alter table includes only clauses specific to encryption. See the Reference Manual for the complete syntax.

Syntax

Encrypt a column:

alter table tablename  add column_name 
     encrypt [with [database.[owner].]keyname]
     [decrypt_default constant expression]

Decrypt an existing column:

alter table tablename modify column_name
     [decrypt [with [database.[owner].]keyname]]

keyname – identifies a key created using create encryption key. The table owner must have select permission on keyname. If keyname is not supplied, Adaptive Server looks for a default key created using create encryption key or alter encryption key as default.

Examples

Example 1 To create an encryption key and encrypt ssn column in existing employee table, enter.

set encryption passwd '4evermore' for key ssn_key
alter table employee modify ssn
         encrypt with ssn_key

If ssn in this encrypted by key1, alter table would cause Adaptive Server to decrypt ssn using key1 and reencrypt ssn using ‘ssn_key’.

Example 2 This adds an encrypted column to an existing table. Because keyname is omitted, Adaptive Server uses the database default encryption key:

alter table sales_mgr
     add bonus money null encrypt

Example 3 To decrypt credit card data that is no longer sensitive, enter:

alter table stolen_ccards
     decrypt ccard

If ccard was encrypted by a key protected by a user-defined password, precede this command with the set encryption key command.

Example 4 To add a decrypt default to an existing encrypted column, enter:

alter table employee
replace salary decrypt_default $0.0

Example 5 A user-defined password that protects a keyname must be set using set encryption passwd before you can execute alter table. To remove a decrypt default from the encrypted salary column without decrypting the column, enter:

alter table employee
     replace salary
     drop decrypt_default

Usage