You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-table-constraints.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@ description: Table constraints support using dedicated SQL pool in Azure Synapse
4
4
author: mstehrani
5
5
ms.author: emtehran
6
6
ms.reviewer: nibruno; wiassaf
7
-
ms.date: 09/05/2019
7
+
ms.date: 02/21/2025
8
8
ms.service: azure-synapse-analytics
9
9
ms.subservice: sql-dw
10
-
ms.topic: conceptual
10
+
ms.topic: concept-article
11
11
ms.custom:
12
12
- azure-synapse
13
13
---
@@ -19,23 +19,23 @@ Learn about table constraints in dedicated SQL pool, including primary key, fore
19
19
## Table constraints
20
20
21
21
Dedicated SQL pool supports these table constraints:
22
-
- PRIMARY KEY is only supported when NONCLUSTERED and NOT ENFORCED are both used.
22
+
- PRIMARY KEY is only supported when NONCLUSTERED and NOT ENFORCED are both used.
23
23
- UNIQUE constraint is only supported when NOT ENFORCED is used.
24
24
25
25
For syntax, check [ALTER TABLE](/sql/t-sql/statements/alter-table-transact-sql) and [CREATE TABLE](/sql/t-sql/statements/create-table-azure-sql-data-warehouse).
26
26
27
-
FOREIGN KEY constraint is not supported in dedicated SQL pool.
27
+
FOREIGN KEY constraint isn't supported in dedicated SQL pool.
28
28
29
29
30
30
## Remarks
31
31
32
-
Having primary key and/or unique key allows dedicated SQL pool engine to generate an optimal execution plan for a query. All values in a primary key column or a unique constraint column should be unique.
32
+
Having primary key and/or unique key allows dedicated SQL pool engine to generate an optimal execution plan for a query. All values in a primary key column or a unique constraint column should be unique.
33
33
34
34
> [!IMPORTANT]
35
35
> After creating a table with primary key or unique constraint in dedicated SQL pool, users need to make sure all values in those columns are unique.
36
36
> A violation of that may cause the query to return inaccurate result.
37
37
38
-
This example shows how a query may return inaccurate result if the primary key or unique constraint column includes duplicate values.
38
+
This example shows how a query may return inaccurate result if the primary key or unique constraint column includes duplicate values.
39
39
40
40
```sql
41
41
-- Create table t1
@@ -48,7 +48,7 @@ INSERT INTO t1 VALUES (2, 200)
48
48
INSERT INTO t1 VALUES (3, 300)
49
49
INSERT INTO t1 VALUES (4, 400)
50
50
51
-
-- Run this query. No primary key or unique constraint. 4 rows returned. Correct result.
51
+
-- Run this query. No primary key or unique constraint. 4 rows returned. Correct result.
52
52
SELECT a1, COUNT(*) AS total FROM t1 GROUP BY a1
53
53
54
54
/*
@@ -65,7 +65,7 @@ a1 total
65
65
-- Add unique constraint
66
66
ALTERTABLE t1 ADD CONSTRAINT unique_t1_a1 unique (a1) NOT ENFORCED
67
67
68
-
-- Re-run this query. 5 rows returned. Incorrect result.
68
+
-- Re-run this query. 5 rows returned. Incorrect result.
69
69
SELECT a1, count(*) AS total FROM t1 GROUP BY a1
70
70
71
71
/*
@@ -86,7 +86,7 @@ ALTER TABLE t1 DROP CONSTRAINT unique_t1_a1
-- Re-run this query. 5 rows returned. Correct result.
146
+
-- Re-run this query. 5 rows returned. Correct result.
147
147
SELECT a1, COUNT(*) AS total FROM t1 GROUP BY a1
148
148
149
149
/*
@@ -174,6 +174,6 @@ Create a dedicated SQL pool table with a unique constraint:
174
174
CREATETABLEt6 (c1 INT UNIQUE NOT ENFORCED, c2 INT);
175
175
```
176
176
177
-
## Next steps
177
+
## Related content
178
178
179
179
After creating the tables for your dedicated SQL pool, the next step is to load data into the table. For a loading tutorial, see [Loading data to dedicated SQL pool](load-data-wideworldimportersdw.md).
0 commit comments