<budget_name>!ADD_RESOURCE

Add an object to a custom budget. The object must be added by reference.

See also:

<budget_name>!REMOVE_RESOURCE, <budget_name>!GET_LINKED_RESOURCES

Syntax

<budget_name>!ADD_RESOURCE( { '<object_reference>' | <reference_statement> } )
Copy

Arguments

'object_reference'

The serialized string representation that resolves to an object. This string is the output of the SYSTEM$REFERENCE function.

reference_statement

A SYSTEM$REFERENCE statement that creates a reference for the object to be added to the budget.

Returns

Successfully added resource to resource group

Access control requirements

The following privileges and roles are required to call this method for a custom budget:

  • ADMIN instance role for the budget instance.

  • USAGE privilege on the database and schema that contain the budget instance.

  • USAGE privilege on the database and schema that contain the object being added (for schema objects).

  • APPLYBUDGET privilege on the object being added.

For more information, see Budgets roles and privileges.

Usage notes

  • You can only add objects to custom budgets.

  • You can only add an object to one custom budget. If an object is currently included in one custom budget and you add that object to a second custom budget, Budgets removes the object from the first custom budget without issuing a warning.

  • You cannot create a reference for the SNOWFLAKE database; and you cannot add it to a budget.

  • Calling this method does not return the object. Because of this, you can’t use method chaining to call another method on the return value of this method. Instead, call each method in a separate SQL statement.

Examples

  1. Create a reference for an object and add the object to a budget.

    Create a reference for table t1:

    SELECT SYSTEM$REFERENCE('TABLE', 't1', 'SESSION', 'APPLYBUDGET');
    
    Copy

    Returns:

    ENT_REF_TABLE_5862683050074_5AEB8D58FB3ACF249F2E35F365A9357C46BB00D7
    

    Add table t1 to budget my_budget in schema budget_db.budget_schema:

    CALL budget_db.budget_schema.my_budget!ADD_RESOURCE(
      'ENT_REF_TABLE_5862683050074_5AEB8D58FB3ACF249F2E35F365A9357C46BB00D7');
    
    Copy
  2. Add an object to a budget by using a SYSTEM$REFERENCE statement.

    Add table t1 to budget my_budget in schema budget_db.budget_schema:

    CALL budget_db.budget_schema.my_budget!ADD_RESOURCE(
      SELECT SYSTEM$REFERENCE('TABLE', 't2', 'SESSION', 'APPLYBUDGET'));
    
    Copy

Error messages

For a list of common error messages and their causes and solutions, see You can’t add or remove objects from a custom budget.