JDBC Driver for Salesforce

Build 22.0.8462

ALTER TABLE Statements

Use the ALTER TABLE statement to add, delete, or modify the columns of a table.

ALTER TABLE Syntax

To add, delete, or modify columns, use the ADD, ALTER, or DROP keywords of the ALTER TABLE statement, as shown in the following example. The ADD keyword accepts a column definition or a comma-separated list of column definitions. The ALTER keyword accepts a column definition. The DROP keyword accepts a column name.

ALTER TABLE <table_name> 
  ADD [ COLUMN ] [ IF NOT EXISTS ]
    <column_definition> | ( <column_definition> [ , ... ] )
	|	ALTER COLUMN <column_definition>
	|	DROP COLUMN [ IF EXISTS ] <column_name> 

<column_definition> ::=
  <column_name>
  <data_type> 
  [ NOT NULL ] 
  [ DEFAULT <literal> ] 
  [ PRIMARY KEY ] 
  [ UNIQUE ] 

The following query adds a new ExternalCustomerId column on the server:

ALTER TABLE MyCustomers ADD (ExternalCustomerId int)

The following query changes the data type of the ExternalCustomerId column:

ALTER TABLE MyCustomers ALTER COLUMN ExternalCustomerId  string

The following query removes the ExternalCustomerId column:

ALTER TABLE MyCustomers DROP COLUMN  ExternalCustomerId

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462