1. Packages
  2. Snowflake
  3. API Docs
  4. TableConstraint
Snowflake v0.55.0 published on Friday, Jun 7, 2024 by Pulumi

snowflake.TableConstraint

Explore with Pulumi AI

snowflake logo
Snowflake v0.55.0 published on Friday, Jun 7, 2024 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as snowflake from "@pulumi/snowflake";
    
    const d = new snowflake.Database("d", {name: "some_db"});
    const s = new snowflake.Schema("s", {
        name: "some_schema",
        database: d.name,
    });
    const t = new snowflake.Table("t", {
        database: d.name,
        schema: s.name,
        name: "some_table",
        columns: [
            {
                name: "col1",
                type: "text",
                nullable: false,
            },
            {
                name: "col2",
                type: "text",
                nullable: false,
            },
            {
                name: "col3",
                type: "text",
                nullable: false,
            },
        ],
    });
    const fkT = new snowflake.Table("fk_t", {
        database: d.name,
        schema: s.name,
        name: "fk_table",
        columns: [
            {
                name: "fk_col1",
                type: "text",
                nullable: false,
            },
            {
                name: "fk_col2",
                type: "text",
                nullable: false,
            },
        ],
    });
    const primaryKey = new snowflake.TableConstraint("primary_key", {
        name: "myconstraint",
        type: "PRIMARY KEY",
        tableId: t.qualifiedName,
        columns: ["col1"],
        comment: "hello world",
    });
    const foreignKey = new snowflake.TableConstraint("foreign_key", {
        name: "myconstraintfk",
        type: "FOREIGN KEY",
        tableId: t.qualifiedName,
        columns: ["col2"],
        foreignKeyProperties: {
            references: {
                tableId: fkT.qualifiedName,
                columns: ["fk_col1"],
            },
        },
        enforced: false,
        deferrable: false,
        initially: "IMMEDIATE",
        comment: "hello fk",
    });
    const unique = new snowflake.TableConstraint("unique", {
        name: "unique",
        type: "UNIQUE",
        tableId: t.qualifiedName,
        columns: ["col3"],
        comment: "hello unique",
    });
    
    import pulumi
    import pulumi_snowflake as snowflake
    
    d = snowflake.Database("d", name="some_db")
    s = snowflake.Schema("s",
        name="some_schema",
        database=d.name)
    t = snowflake.Table("t",
        database=d.name,
        schema=s.name,
        name="some_table",
        columns=[
            snowflake.TableColumnArgs(
                name="col1",
                type="text",
                nullable=False,
            ),
            snowflake.TableColumnArgs(
                name="col2",
                type="text",
                nullable=False,
            ),
            snowflake.TableColumnArgs(
                name="col3",
                type="text",
                nullable=False,
            ),
        ])
    fk_t = snowflake.Table("fk_t",
        database=d.name,
        schema=s.name,
        name="fk_table",
        columns=[
            snowflake.TableColumnArgs(
                name="fk_col1",
                type="text",
                nullable=False,
            ),
            snowflake.TableColumnArgs(
                name="fk_col2",
                type="text",
                nullable=False,
            ),
        ])
    primary_key = snowflake.TableConstraint("primary_key",
        name="myconstraint",
        type="PRIMARY KEY",
        table_id=t.qualified_name,
        columns=["col1"],
        comment="hello world")
    foreign_key = snowflake.TableConstraint("foreign_key",
        name="myconstraintfk",
        type="FOREIGN KEY",
        table_id=t.qualified_name,
        columns=["col2"],
        foreign_key_properties=snowflake.TableConstraintForeignKeyPropertiesArgs(
            references=snowflake.TableConstraintForeignKeyPropertiesReferencesArgs(
                table_id=fk_t.qualified_name,
                columns=["fk_col1"],
            ),
        ),
        enforced=False,
        deferrable=False,
        initially="IMMEDIATE",
        comment="hello fk")
    unique = snowflake.TableConstraint("unique",
        name="unique",
        type="UNIQUE",
        table_id=t.qualified_name,
        columns=["col3"],
        comment="hello unique")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-snowflake/sdk/go/snowflake"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		d, err := snowflake.NewDatabase(ctx, "d", &snowflake.DatabaseArgs{
    			Name: pulumi.String("some_db"),
    		})
    		if err != nil {
    			return err
    		}
    		s, err := snowflake.NewSchema(ctx, "s", &snowflake.SchemaArgs{
    			Name:     pulumi.String("some_schema"),
    			Database: d.Name,
    		})
    		if err != nil {
    			return err
    		}
    		t, err := snowflake.NewTable(ctx, "t", &snowflake.TableArgs{
    			Database: d.Name,
    			Schema:   s.Name,
    			Name:     pulumi.String("some_table"),
    			Columns: snowflake.TableColumnArray{
    				&snowflake.TableColumnArgs{
    					Name:     pulumi.String("col1"),
    					Type:     pulumi.String("text"),
    					Nullable: pulumi.Bool(false),
    				},
    				&snowflake.TableColumnArgs{
    					Name:     pulumi.String("col2"),
    					Type:     pulumi.String("text"),
    					Nullable: pulumi.Bool(false),
    				},
    				&snowflake.TableColumnArgs{
    					Name:     pulumi.String("col3"),
    					Type:     pulumi.String("text"),
    					Nullable: pulumi.Bool(false),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		fkT, err := snowflake.NewTable(ctx, "fk_t", &snowflake.TableArgs{
    			Database: d.Name,
    			Schema:   s.Name,
    			Name:     pulumi.String("fk_table"),
    			Columns: snowflake.TableColumnArray{
    				&snowflake.TableColumnArgs{
    					Name:     pulumi.String("fk_col1"),
    					Type:     pulumi.String("text"),
    					Nullable: pulumi.Bool(false),
    				},
    				&snowflake.TableColumnArgs{
    					Name:     pulumi.String("fk_col2"),
    					Type:     pulumi.String("text"),
    					Nullable: pulumi.Bool(false),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = snowflake.NewTableConstraint(ctx, "primary_key", &snowflake.TableConstraintArgs{
    			Name:    pulumi.String("myconstraint"),
    			Type:    pulumi.String("PRIMARY KEY"),
    			TableId: t.QualifiedName,
    			Columns: pulumi.StringArray{
    				pulumi.String("col1"),
    			},
    			Comment: pulumi.String("hello world"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = snowflake.NewTableConstraint(ctx, "foreign_key", &snowflake.TableConstraintArgs{
    			Name:    pulumi.String("myconstraintfk"),
    			Type:    pulumi.String("FOREIGN KEY"),
    			TableId: t.QualifiedName,
    			Columns: pulumi.StringArray{
    				pulumi.String("col2"),
    			},
    			ForeignKeyProperties: &snowflake.TableConstraintForeignKeyPropertiesArgs{
    				References: &snowflake.TableConstraintForeignKeyPropertiesReferencesArgs{
    					TableId: fkT.QualifiedName,
    					Columns: pulumi.StringArray{
    						pulumi.String("fk_col1"),
    					},
    				},
    			},
    			Enforced:   pulumi.Bool(false),
    			Deferrable: pulumi.Bool(false),
    			Initially:  pulumi.String("IMMEDIATE"),
    			Comment:    pulumi.String("hello fk"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = snowflake.NewTableConstraint(ctx, "unique", &snowflake.TableConstraintArgs{
    			Name:    pulumi.String("unique"),
    			Type:    pulumi.String("UNIQUE"),
    			TableId: t.QualifiedName,
    			Columns: pulumi.StringArray{
    				pulumi.String("col3"),
    			},
    			Comment: pulumi.String("hello unique"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Snowflake = Pulumi.Snowflake;
    
    return await Deployment.RunAsync(() => 
    {
        var d = new Snowflake.Database("d", new()
        {
            Name = "some_db",
        });
    
        var s = new Snowflake.Schema("s", new()
        {
            Name = "some_schema",
            Database = d.Name,
        });
    
        var t = new Snowflake.Table("t", new()
        {
            Database = d.Name,
            Schema = s.Name,
            Name = "some_table",
            Columns = new[]
            {
                new Snowflake.Inputs.TableColumnArgs
                {
                    Name = "col1",
                    Type = "text",
                    Nullable = false,
                },
                new Snowflake.Inputs.TableColumnArgs
                {
                    Name = "col2",
                    Type = "text",
                    Nullable = false,
                },
                new Snowflake.Inputs.TableColumnArgs
                {
                    Name = "col3",
                    Type = "text",
                    Nullable = false,
                },
            },
        });
    
        var fkT = new Snowflake.Table("fk_t", new()
        {
            Database = d.Name,
            Schema = s.Name,
            Name = "fk_table",
            Columns = new[]
            {
                new Snowflake.Inputs.TableColumnArgs
                {
                    Name = "fk_col1",
                    Type = "text",
                    Nullable = false,
                },
                new Snowflake.Inputs.TableColumnArgs
                {
                    Name = "fk_col2",
                    Type = "text",
                    Nullable = false,
                },
            },
        });
    
        var primaryKey = new Snowflake.TableConstraint("primary_key", new()
        {
            Name = "myconstraint",
            Type = "PRIMARY KEY",
            TableId = t.QualifiedName,
            Columns = new[]
            {
                "col1",
            },
            Comment = "hello world",
        });
    
        var foreignKey = new Snowflake.TableConstraint("foreign_key", new()
        {
            Name = "myconstraintfk",
            Type = "FOREIGN KEY",
            TableId = t.QualifiedName,
            Columns = new[]
            {
                "col2",
            },
            ForeignKeyProperties = new Snowflake.Inputs.TableConstraintForeignKeyPropertiesArgs
            {
                References = new Snowflake.Inputs.TableConstraintForeignKeyPropertiesReferencesArgs
                {
                    TableId = fkT.QualifiedName,
                    Columns = new[]
                    {
                        "fk_col1",
                    },
                },
            },
            Enforced = false,
            Deferrable = false,
            Initially = "IMMEDIATE",
            Comment = "hello fk",
        });
    
        var unique = new Snowflake.TableConstraint("unique", new()
        {
            Name = "unique",
            Type = "UNIQUE",
            TableId = t.QualifiedName,
            Columns = new[]
            {
                "col3",
            },
            Comment = "hello unique",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.snowflake.Database;
    import com.pulumi.snowflake.DatabaseArgs;
    import com.pulumi.snowflake.Schema;
    import com.pulumi.snowflake.SchemaArgs;
    import com.pulumi.snowflake.Table;
    import com.pulumi.snowflake.TableArgs;
    import com.pulumi.snowflake.inputs.TableColumnArgs;
    import com.pulumi.snowflake.TableConstraint;
    import com.pulumi.snowflake.TableConstraintArgs;
    import com.pulumi.snowflake.inputs.TableConstraintForeignKeyPropertiesArgs;
    import com.pulumi.snowflake.inputs.TableConstraintForeignKeyPropertiesReferencesArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var d = new Database("d", DatabaseArgs.builder()
                .name("some_db")
                .build());
    
            var s = new Schema("s", SchemaArgs.builder()
                .name("some_schema")
                .database(d.name())
                .build());
    
            var t = new Table("t", TableArgs.builder()
                .database(d.name())
                .schema(s.name())
                .name("some_table")
                .columns(            
                    TableColumnArgs.builder()
                        .name("col1")
                        .type("text")
                        .nullable(false)
                        .build(),
                    TableColumnArgs.builder()
                        .name("col2")
                        .type("text")
                        .nullable(false)
                        .build(),
                    TableColumnArgs.builder()
                        .name("col3")
                        .type("text")
                        .nullable(false)
                        .build())
                .build());
    
            var fkT = new Table("fkT", TableArgs.builder()
                .database(d.name())
                .schema(s.name())
                .name("fk_table")
                .columns(            
                    TableColumnArgs.builder()
                        .name("fk_col1")
                        .type("text")
                        .nullable(false)
                        .build(),
                    TableColumnArgs.builder()
                        .name("fk_col2")
                        .type("text")
                        .nullable(false)
                        .build())
                .build());
    
            var primaryKey = new TableConstraint("primaryKey", TableConstraintArgs.builder()
                .name("myconstraint")
                .type("PRIMARY KEY")
                .tableId(t.qualifiedName())
                .columns("col1")
                .comment("hello world")
                .build());
    
            var foreignKey = new TableConstraint("foreignKey", TableConstraintArgs.builder()
                .name("myconstraintfk")
                .type("FOREIGN KEY")
                .tableId(t.qualifiedName())
                .columns("col2")
                .foreignKeyProperties(TableConstraintForeignKeyPropertiesArgs.builder()
                    .references(TableConstraintForeignKeyPropertiesReferencesArgs.builder()
                        .tableId(fkT.qualifiedName())
                        .columns("fk_col1")
                        .build())
                    .build())
                .enforced(false)
                .deferrable(false)
                .initially("IMMEDIATE")
                .comment("hello fk")
                .build());
    
            var unique = new TableConstraint("unique", TableConstraintArgs.builder()
                .name("unique")
                .type("UNIQUE")
                .tableId(t.qualifiedName())
                .columns("col3")
                .comment("hello unique")
                .build());
    
        }
    }
    
    resources:
      d:
        type: snowflake:Database
        properties:
          name: some_db
      s:
        type: snowflake:Schema
        properties:
          name: some_schema
          database: ${d.name}
      t:
        type: snowflake:Table
        properties:
          database: ${d.name}
          schema: ${s.name}
          name: some_table
          columns:
            - name: col1
              type: text
              nullable: false
            - name: col2
              type: text
              nullable: false
            - name: col3
              type: text
              nullable: false
      fkT:
        type: snowflake:Table
        name: fk_t
        properties:
          database: ${d.name}
          schema: ${s.name}
          name: fk_table
          columns:
            - name: fk_col1
              type: text
              nullable: false
            - name: fk_col2
              type: text
              nullable: false
      primaryKey:
        type: snowflake:TableConstraint
        name: primary_key
        properties:
          name: myconstraint
          type: PRIMARY KEY
          tableId: ${t.qualifiedName}
          columns:
            - col1
          comment: hello world
      foreignKey:
        type: snowflake:TableConstraint
        name: foreign_key
        properties:
          name: myconstraintfk
          type: FOREIGN KEY
          tableId: ${t.qualifiedName}
          columns:
            - col2
          foreignKeyProperties:
            references:
              tableId: ${fkT.qualifiedName}
              columns:
                - fk_col1
          enforced: false
          deferrable: false
          initially: IMMEDIATE
          comment: hello fk
      unique:
        type: snowflake:TableConstraint
        properties:
          name: unique
          type: UNIQUE
          tableId: ${t.qualifiedName}
          columns:
            - col3
          comment: hello unique
    

    Create TableConstraint Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new TableConstraint(name: string, args: TableConstraintArgs, opts?: CustomResourceOptions);
    @overload
    def TableConstraint(resource_name: str,
                        args: TableConstraintArgs,
                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def TableConstraint(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        columns: Optional[Sequence[str]] = None,
                        table_id: Optional[str] = None,
                        type: Optional[str] = None,
                        comment: Optional[str] = None,
                        deferrable: Optional[bool] = None,
                        enable: Optional[bool] = None,
                        enforced: Optional[bool] = None,
                        foreign_key_properties: Optional[TableConstraintForeignKeyPropertiesArgs] = None,
                        initially: Optional[str] = None,
                        name: Optional[str] = None,
                        rely: Optional[bool] = None,
                        validate: Optional[bool] = None)
    func NewTableConstraint(ctx *Context, name string, args TableConstraintArgs, opts ...ResourceOption) (*TableConstraint, error)
    public TableConstraint(string name, TableConstraintArgs args, CustomResourceOptions? opts = null)
    public TableConstraint(String name, TableConstraintArgs args)
    public TableConstraint(String name, TableConstraintArgs args, CustomResourceOptions options)
    
    type: snowflake:TableConstraint
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args TableConstraintArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args TableConstraintArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args TableConstraintArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TableConstraintArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TableConstraintArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var tableConstraintResource = new Snowflake.TableConstraint("tableConstraintResource", new()
    {
        Columns = new[]
        {
            "string",
        },
        TableId = "string",
        Type = "string",
        Deferrable = false,
        Enable = false,
        Enforced = false,
        ForeignKeyProperties = new Snowflake.Inputs.TableConstraintForeignKeyPropertiesArgs
        {
            References = new Snowflake.Inputs.TableConstraintForeignKeyPropertiesReferencesArgs
            {
                Columns = new[]
                {
                    "string",
                },
                TableId = "string",
            },
            Match = "string",
            OnDelete = "string",
            OnUpdate = "string",
        },
        Initially = "string",
        Name = "string",
        Rely = false,
        Validate = false,
    });
    
    example, err := snowflake.NewTableConstraint(ctx, "tableConstraintResource", &snowflake.TableConstraintArgs{
    	Columns: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	TableId:    pulumi.String("string"),
    	Type:       pulumi.String("string"),
    	Deferrable: pulumi.Bool(false),
    	Enable:     pulumi.Bool(false),
    	Enforced:   pulumi.Bool(false),
    	ForeignKeyProperties: &snowflake.TableConstraintForeignKeyPropertiesArgs{
    		References: &snowflake.TableConstraintForeignKeyPropertiesReferencesArgs{
    			Columns: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			TableId: pulumi.String("string"),
    		},
    		Match:    pulumi.String("string"),
    		OnDelete: pulumi.String("string"),
    		OnUpdate: pulumi.String("string"),
    	},
    	Initially: pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	Rely:      pulumi.Bool(false),
    	Validate:  pulumi.Bool(false),
    })
    
    var tableConstraintResource = new TableConstraint("tableConstraintResource", TableConstraintArgs.builder()
        .columns("string")
        .tableId("string")
        .type("string")
        .deferrable(false)
        .enable(false)
        .enforced(false)
        .foreignKeyProperties(TableConstraintForeignKeyPropertiesArgs.builder()
            .references(TableConstraintForeignKeyPropertiesReferencesArgs.builder()
                .columns("string")
                .tableId("string")
                .build())
            .match("string")
            .onDelete("string")
            .onUpdate("string")
            .build())
        .initially("string")
        .name("string")
        .rely(false)
        .validate(false)
        .build());
    
    table_constraint_resource = snowflake.TableConstraint("tableConstraintResource",
        columns=["string"],
        table_id="string",
        type="string",
        deferrable=False,
        enable=False,
        enforced=False,
        foreign_key_properties=snowflake.TableConstraintForeignKeyPropertiesArgs(
            references=snowflake.TableConstraintForeignKeyPropertiesReferencesArgs(
                columns=["string"],
                table_id="string",
            ),
            match="string",
            on_delete="string",
            on_update="string",
        ),
        initially="string",
        name="string",
        rely=False,
        validate=False)
    
    const tableConstraintResource = new snowflake.TableConstraint("tableConstraintResource", {
        columns: ["string"],
        tableId: "string",
        type: "string",
        deferrable: false,
        enable: false,
        enforced: false,
        foreignKeyProperties: {
            references: {
                columns: ["string"],
                tableId: "string",
            },
            match: "string",
            onDelete: "string",
            onUpdate: "string",
        },
        initially: "string",
        name: "string",
        rely: false,
        validate: false,
    });
    
    type: snowflake:TableConstraint
    properties:
        columns:
            - string
        deferrable: false
        enable: false
        enforced: false
        foreignKeyProperties:
            match: string
            onDelete: string
            onUpdate: string
            references:
                columns:
                    - string
                tableId: string
        initially: string
        name: string
        rely: false
        tableId: string
        type: string
        validate: false
    

    TableConstraint Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The TableConstraint resource accepts the following input properties:

    Columns List<string>
    Columns to use in constraint key
    TableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    Type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    Comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    Deferrable bool
    Whether the constraint is deferrable
    Enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    Enforced bool
    Whether the constraint is enforced
    ForeignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    Initially string
    Whether the constraint is initially deferred or immediate
    Name string
    Name of constraint
    Rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    Validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    Columns []string
    Columns to use in constraint key
    TableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    Type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    Comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    Deferrable bool
    Whether the constraint is deferrable
    Enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    Enforced bool
    Whether the constraint is enforced
    ForeignKeyProperties TableConstraintForeignKeyPropertiesArgs
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    Initially string
    Whether the constraint is initially deferred or immediate
    Name string
    Name of constraint
    Rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    Validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns List<String>
    Columns to use in constraint key
    tableId String
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type String
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    comment String
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable Boolean
    Whether the constraint is deferrable
    enable Boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced Boolean
    Whether the constraint is enforced
    foreignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially String
    Whether the constraint is initially deferred or immediate
    name String
    Name of constraint
    rely Boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    validate Boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns string[]
    Columns to use in constraint key
    tableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable boolean
    Whether the constraint is deferrable
    enable boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced boolean
    Whether the constraint is enforced
    foreignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially string
    Whether the constraint is initially deferred or immediate
    name string
    Name of constraint
    rely boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    validate boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns Sequence[str]
    Columns to use in constraint key
    table_id str
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type str
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    comment str
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable bool
    Whether the constraint is deferrable
    enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced bool
    Whether the constraint is enforced
    foreign_key_properties TableConstraintForeignKeyPropertiesArgs
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially str
    Whether the constraint is initially deferred or immediate
    name str
    Name of constraint
    rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns List<String>
    Columns to use in constraint key
    tableId String
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type String
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    comment String
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable Boolean
    Whether the constraint is deferrable
    enable Boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced Boolean
    Whether the constraint is enforced
    foreignKeyProperties Property Map
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially String
    Whether the constraint is initially deferred or immediate
    name String
    Name of constraint
    rely Boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    validate Boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the TableConstraint resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing TableConstraint Resource

    Get an existing TableConstraint resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: TableConstraintState, opts?: CustomResourceOptions): TableConstraint
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            columns: Optional[Sequence[str]] = None,
            comment: Optional[str] = None,
            deferrable: Optional[bool] = None,
            enable: Optional[bool] = None,
            enforced: Optional[bool] = None,
            foreign_key_properties: Optional[TableConstraintForeignKeyPropertiesArgs] = None,
            initially: Optional[str] = None,
            name: Optional[str] = None,
            rely: Optional[bool] = None,
            table_id: Optional[str] = None,
            type: Optional[str] = None,
            validate: Optional[bool] = None) -> TableConstraint
    func GetTableConstraint(ctx *Context, name string, id IDInput, state *TableConstraintState, opts ...ResourceOption) (*TableConstraint, error)
    public static TableConstraint Get(string name, Input<string> id, TableConstraintState? state, CustomResourceOptions? opts = null)
    public static TableConstraint get(String name, Output<String> id, TableConstraintState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Columns List<string>
    Columns to use in constraint key
    Comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    Deferrable bool
    Whether the constraint is deferrable
    Enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    Enforced bool
    Whether the constraint is enforced
    ForeignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    Initially string
    Whether the constraint is initially deferred or immediate
    Name string
    Name of constraint
    Rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    TableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    Type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    Validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    Columns []string
    Columns to use in constraint key
    Comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    Deferrable bool
    Whether the constraint is deferrable
    Enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    Enforced bool
    Whether the constraint is enforced
    ForeignKeyProperties TableConstraintForeignKeyPropertiesArgs
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    Initially string
    Whether the constraint is initially deferred or immediate
    Name string
    Name of constraint
    Rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    TableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    Type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    Validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns List<String>
    Columns to use in constraint key
    comment String
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable Boolean
    Whether the constraint is deferrable
    enable Boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced Boolean
    Whether the constraint is enforced
    foreignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially String
    Whether the constraint is initially deferred or immediate
    name String
    Name of constraint
    rely Boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    tableId String
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type String
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    validate Boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns string[]
    Columns to use in constraint key
    comment string
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable boolean
    Whether the constraint is deferrable
    enable boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced boolean
    Whether the constraint is enforced
    foreignKeyProperties TableConstraintForeignKeyProperties
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially string
    Whether the constraint is initially deferred or immediate
    name string
    Name of constraint
    rely boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    tableId string
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type string
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    validate boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns Sequence[str]
    Columns to use in constraint key
    comment str
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable bool
    Whether the constraint is deferrable
    enable bool
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced bool
    Whether the constraint is enforced
    foreign_key_properties TableConstraintForeignKeyPropertiesArgs
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially str
    Whether the constraint is initially deferred or immediate
    name str
    Name of constraint
    rely bool
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    table_id str
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type str
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    validate bool
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.
    columns List<String>
    Columns to use in constraint key
    comment String
    Comment for the table constraint

    Deprecated: Not used. Will be removed.

    deferrable Boolean
    Whether the constraint is deferrable
    enable Boolean
    Specifies whether the constraint is enabled or disabled. These properties are provided for compatibility with Oracle.
    enforced Boolean
    Whether the constraint is enforced
    foreignKeyProperties Property Map
    Additional properties when type is set to foreign key. Not applicable for primary/unique keys
    initially String
    Whether the constraint is initially deferred or immediate
    name String
    Name of constraint
    rely Boolean
    Specifies whether a constraint in NOVALIDATE mode is taken into account during query rewrite.
    tableId String
    Identifier for table to create constraint on. Format must follow: ""<dbname>"."<schemaname>"."<tablename>"" or "<dbname>.<schemaname>.<tablename>" (snowflaketable.mytable.id)
    type String
    Type of constraint, one of 'UNIQUE', 'PRIMARY KEY', or 'FOREIGN KEY'
    validate Boolean
    Specifies whether to validate existing data on the table when a constraint is created. Only used in conjunction with the ENABLE property.

    Supporting Types

    TableConstraintForeignKeyProperties, TableConstraintForeignKeyPropertiesArgs

    References TableConstraintForeignKeyPropertiesReferences
    The table and columns that the foreign key references.
    Match string
    The match type for the foreign key. Not applicable for primary/unique keys
    OnDelete string
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    OnUpdate string
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys
    References TableConstraintForeignKeyPropertiesReferences
    The table and columns that the foreign key references.
    Match string
    The match type for the foreign key. Not applicable for primary/unique keys
    OnDelete string
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    OnUpdate string
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys
    references TableConstraintForeignKeyPropertiesReferences
    The table and columns that the foreign key references.
    match String
    The match type for the foreign key. Not applicable for primary/unique keys
    onDelete String
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    onUpdate String
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys
    references TableConstraintForeignKeyPropertiesReferences
    The table and columns that the foreign key references.
    match string
    The match type for the foreign key. Not applicable for primary/unique keys
    onDelete string
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    onUpdate string
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys
    references TableConstraintForeignKeyPropertiesReferences
    The table and columns that the foreign key references.
    match str
    The match type for the foreign key. Not applicable for primary/unique keys
    on_delete str
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    on_update str
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys
    references Property Map
    The table and columns that the foreign key references.
    match String
    The match type for the foreign key. Not applicable for primary/unique keys
    onDelete String
    Specifies the action performed when the primary/unique key for the foreign key is deleted. Not applicable for primary/unique keys
    onUpdate String
    Specifies the action performed when the primary/unique key for the foreign key is updated. Not applicable for primary/unique keys

    TableConstraintForeignKeyPropertiesReferences, TableConstraintForeignKeyPropertiesReferencesArgs

    Columns List<string>
    Columns to use in foreign key reference
    TableId string
    Name of constraint
    Columns []string
    Columns to use in foreign key reference
    TableId string
    Name of constraint
    columns List<String>
    Columns to use in foreign key reference
    tableId String
    Name of constraint
    columns string[]
    Columns to use in foreign key reference
    tableId string
    Name of constraint
    columns Sequence[str]
    Columns to use in foreign key reference
    table_id str
    Name of constraint
    columns List<String>
    Columns to use in foreign key reference
    tableId String
    Name of constraint

    Import

    $ pulumi import snowflake:index/tableConstraint:TableConstraint example 'myconstraintfk❄️FOREIGN KEY❄️test|test|table'
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Snowflake pulumi/pulumi-snowflake
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the snowflake Terraform Provider.
    snowflake logo
    Snowflake v0.55.0 published on Friday, Jun 7, 2024 by Pulumi