Table properties and table options
一個pplies to:Databricks SQLDatabricks Runtime
Defines user defined tags for tables and views.
一個table property is a key-value pair which you can initialize when you perform aCREATE TABLEor aCREATE VIEW. You canUNSETexisting orSETnew or existing table properties using一個LTER TABLEor一個LTER VIEW.
You can use table properties to tag tables with information not tracked by SQL.
The purpose of table options is to pass storage properties to the underlying storage, such as SERDE properties to Hive.
一個table option is a key-value pair which you can initialize when you perform aCREATE TABLE. You cannot
SET
orUNSET
a table option.
TBLPROPERTIES
Sets one or more table properties in a new table or view.
You can use table properties to tag tables with information not tracked by SQL.
Syntax
TBLPROPERTIES(property_key[=]property_val[,...])property_key{identifier[....]|string_literal}
Parameters
property_key
The property key. The key can consist of one or moreidentifiersseparated by a dot, or a string literal.
Property keys must be unique and are case sensitive.
property_val
The value for the property. The value must be a BOOLEAN, STRING, INTEGER, or DECIMAL literal.
SET TBLPROPERTIES
Sets one or more table properties in an existing table or view.
Syntax
SETTBLPROPERTIES(property_key[=]property_val[,...])property_key{identifier[....]|string_literal}
Parameters
property_key
The property key. The key can consist of one or moreidentifiersseparated by a dot, or a string literal.
Property keys must be unique and are case sensitive.
property_val
The new value for the property. The value must be a BOOLEAN, STRING, INTEGER, or DECIMAL literal.
UNSET TBLPROPERTIES
Removes one or more table properties from a table or view.
Syntax
UNSETTBLPROPERTIES[IFEXISTS](property_key[,...])property_key{identifier[....]|string_literal}
Parameters
IF EXISTS
一個n optional clause directing Databricks SQL not to raise an error if any of the property keys do not exist.
property_key
The property key to remove. The key can consist of one or moreidentifiersseparated by a dot, or a string literal.
Property keys are case sensitive. If
property_key
doesn’t exist and error is raised unlessIFEXISTS
has been specified.
OPTIONS
Sets one or more table options in a new table.
The purpose of table options is to pass storage properties to the underlying storage, such as SERDE properties to Hive.
Specifying table options for Delta Lake tables will also echo these options as table properties.
Parameters
property_key
The property key. The key can consist of one or moreidentifiersseparated by a dot, or a string literal.
Property keys must be unique and are case sensitive.
property_val
The value for the property. The value must be a BOOLEAN, STRING, INTEGER, or DECIMAL literal.
Reserved table property keys
Databricks reserves some property keys for its own use and raises an error if you attempt to use them:
external
UseCREATE EXTERNAL TABLEto create an external table.
location
Use the
LOCATION
clauses of一個LTER TABLEandCREATE TABLEto set a table location.owner
Use the
[SET]OWNERTO
clause of一個LTER TABLEand一個LTER VIEWto transfer ownership of a table or view. SET is allowed as an optional keyword in Databricks SQL.provider
Use the
USING
clause ofCREATE TABLEto set the data source of a table
You should not use property keys starting with theoption
identifier. This prefix identifier will be filtered out inSHOW TBLPROPERTIES. Theoption
prefix is also used to displaytable options.
Common TBLPROPERTIES and OPTIONS keys
The following settings are commonly used with Delta Lake:
delta.appendOnly
: Set totrue
to disableUPDATE
andDELETE
operations.delta.dataSkippingNumIndexedCols
: Set to the number of leading column for which to collect and consider statistics.delta.deletedFileRetentionDuration
: Set to an interval such as'interval7days'
to control whenVACUUM
is allowed to delete files.delta.logRetentionDuration
: Set to an interval such as'interval60days'
to control how long history is kept for time travel queries.