|
1 |
| ---- |
| 1 | +--- |
2 | 2 | title: "tempdb Database (SQL Server PDW)"
|
3 | 3 | author: "barbkess"
|
4 | 4 | ms.author: "barbkess"
|
5 | 5 | manager: "jhubbard"
|
6 | 6 | ms.prod: "analytics-platform-system"
|
7 | 7 | ms.technology: "mpp-data-warehouse"
|
8 |
| -ms.custom: na |
9 |
| -ms.date: 01/13/2017 |
10 |
| -ms.reviewer: na |
11 |
| -ms.suite: na |
12 |
| -ms.tgt_pltfrm: na |
13 |
| -ms.topic: article |
14 |
| -ms.assetid: 5840033d-2dc6-4576-8a5f-067e2a58b170 |
15 |
| -caps.latest.revision: 22 |
16 |
| - |
17 |
| ---- |
18 |
| -# tempdb Database |
19 |
| -**tempdb** is a SQL Server PDW system database that stores local temporary tables for user databases. Temporary tables are often used to improve query performance. For example, you can use a temporary table to modularize a script, and reuse computed data. |
20 |
| - |
21 |
| -For more information about system databases, see [System Databases](system-databases.md). |
22 |
| - |
23 |
| -## <a name="Basics"></a>Key Terms and Concepts |
24 |
| -*local temporary table* |
25 |
| -A *local temporary table* uses the # prefix before the table name and is a temporary table created by a local user session. Each session can only access the data in local temporary tables for its own session. |
26 |
| - |
27 |
| -Each session can view the metadata for local temporary tables in all sessions. For example, all sessions can view the metadata for all local temporary tables with the `SELECT * FROM tempdb.sys.tables` query. |
28 |
| - |
29 |
| -global temporary table |
30 |
| -*Global temporary tables*, supported in SQL Server with the ## syntax, are not supported in this release of SQL Server PDW. |
31 |
| - |
32 |
| -pdwtempdb |
33 |
| -**pdwtempdb** is the database that stores local temporary tables. |
34 |
| - |
35 |
| -PDW does not implement temporary tables by using the SQL Server**tempdb** database. Instead, PDW stores them in a database called pdwtempdb. This database exists on each Compute node and is invisible to the user through the PDW interfaces. In the Admin Console, on the storage page, you will see these accounted for in a PDW system database called **tempdb-sql**. |
36 |
| - |
37 |
| -tempdb |
38 |
| -**tempdb** is the SQL Server tempdb database. It uses minimal logging. SQL Server uses tempdb on the Compute nodes to store temporary tables that it needs in the course of performing SQL Server operations. |
39 |
| - |
40 |
| -SQL Server PDW drops tables from **tempdb** when: |
41 |
| - |
42 |
| -- The DROP TABLE statement is executed. |
43 |
| - |
44 |
| -- A session is disconnected. Only temporary tables for the session are dropped. |
45 |
| - |
46 |
| -- The appliance is shutdown. |
47 |
| - |
48 |
| -- The Control node has a cluster failover. |
49 |
| - |
50 |
| -## General Remarks |
51 |
| -SQL Server PDW performs the same operations on temporary tables and permanent tables unless explicitly stated otherwise. For example, the data in local temporary tables, just like permanent tables, is either distributed or replicated across the Compute nodes. |
52 |
| - |
53 |
| -## <a name="LimitationsRestrictions"></a>Limitations and Restrictions |
54 |
| -Limitations and restrictions on the SQL Server PDW**tempdb** database. You *cannot:* |
55 |
| - |
56 |
| -- Create a global temporary table that begins with ##. |
57 |
| - |
58 |
| -- Perform a backup or restore of **tempdb**. |
59 |
| - |
60 |
| -- Modify permissions to **tempdb** with the **GRANT**, **DENY**, or **REVOKE** statements. |
61 |
| - |
62 |
| -- Execute **DBCC SHRINKLOG** for **tempdb**tempdb. |
63 |
| - |
64 |
| -- Perform DDL operations on **tempdb**. There are a couple exceptions to this. For details, see the following list of limitations and restrictions on local temporary tables. |
65 |
| - |
66 |
| -Limitations and restrictions on local temporary tables. You *cannot:* |
67 |
| - |
68 |
| -- Rename a temporary table |
69 |
| - |
70 |
| -- Create partitions, views, or non-clustered indexes on a temporary table. **ALTER INDEX** can be used to rebuild a clustered index for a table created with one. |
71 |
| - |
72 |
| -- Modify permissions to temporary tables with the GRANT, DENY, or REVOKE statements. |
73 |
| - |
74 |
| -- Run database console commands on temporary tables. |
75 |
| - |
76 |
| -- Use the same name for two or more temporary tables within the same batch. If more than one local temporary table is used within a batch, each must have a unique name. If multiple sessions are running the same batch and creating the same local temporary table, SQL Server PDW internally appends a numeric suffix to the local temporary table name to maintain a unique name for each local temporary table. |
77 |
| - |
78 |
| -> [!NOTE] |
79 |
| -> You *can* create and update statistics on a temporary table.**ALTER INDEX** can be used to rebuild a clustered index. |
80 |
| - |
81 |
| -## Permissions |
82 |
| -Any user can create temporary objects in tempdb. Users can only access their own objects, unless they receive additional permissions. It is possible to revoke the connect permission to tempdb to prevent a user from using tempdb, but this is not recommended as some routine operations require the use of tempdb. |
83 |
| - |
84 |
| -## <a name="RelatedTasks"></a>Related Tasks |
85 |
| - |
86 |
| -|Tasks|Description| |
87 |
| -|---------|---------------| |
88 |
| -|Create a table in **tempdb**.|You can create a user temporary table with the CREATE TABLE and CREATE TABLE AS SELECT statements. For more information, see [CREATE TABLE](../t-sql/statements/create-table-azure-sql-data-warehouse.md) and [CREATE TABLE AS SELECT](../t-sql/statements/create-table-as-select-azure-sql-data-warehouse.md).| |
89 |
| -|View a list of existing tables in **tempdb**.|`SELECT * FROM tempdb.sys.tables;`| |
90 |
| -|View a list of existing columns in **tempdb**.|`SELECT * FROM tempdb.sys.columns;`| |
91 |
| -|View a list of existing objects in **tempdb**.|`SELECT * FROM tempdb.sys.objects;`| |
92 |
| - |
93 |
| -<!-- MISSING LINKS |
94 |
| -## See Also |
95 |
| -[Common Metadata Query Examples (SQL Server PDW)](../sqlpdw/common-metadata-query-examples-sql-server-pdw.md) |
96 |
| ---> |
97 |
| - |
| 8 | +ms.custom: na |
| 9 | +ms.date: 01/13/2017 |
| 10 | +ms.reviewer: na |
| 11 | +ms.suite: na |
| 12 | +ms.tgt_pltfrm: na |
| 13 | +ms.topic: article |
| 14 | +ms.assetid: 5840033d-2dc6-4576-8a5f-067e2a58b170 |
| 15 | +caps.latest.revision: 22 |
| 16 | + |
| 17 | +ms.workload: "On Demand" |
| 18 | +--- |
| 19 | +# tempdb Database |
| 20 | +**tempdb** is a SQL Server PDW system database that stores local temporary tables for user databases. Temporary tables are often used to improve query performance. For example, you can use a temporary table to modularize a script, and reuse computed data. |
| 21 | + |
| 22 | +For more information about system databases, see [System Databases](system-databases.md). |
| 23 | + |
| 24 | +## <a name="Basics"></a>Key Terms and Concepts |
| 25 | +*local temporary table* |
| 26 | +A *local temporary table* uses the # prefix before the table name and is a temporary table created by a local user session. Each session can only access the data in local temporary tables for its own session. |
| 27 | + |
| 28 | +Each session can view the metadata for local temporary tables in all sessions. For example, all sessions can view the metadata for all local temporary tables with the `SELECT * FROM tempdb.sys.tables` query. |
| 29 | + |
| 30 | +global temporary table |
| 31 | +*Global temporary tables*, supported in SQL Server with the ## syntax, are not supported in this release of SQL Server PDW. |
| 32 | + |
| 33 | +pdwtempdb |
| 34 | +**pdwtempdb** is the database that stores local temporary tables. |
| 35 | + |
| 36 | +PDW does not implement temporary tables by using the SQL Server**tempdb** database. Instead, PDW stores them in a database called pdwtempdb. This database exists on each Compute node and is invisible to the user through the PDW interfaces. In the Admin Console, on the storage page, you will see these accounted for in a PDW system database called **tempdb-sql**. |
| 37 | + |
| 38 | +tempdb |
| 39 | +**tempdb** is the SQL Server tempdb database. It uses minimal logging. SQL Server uses tempdb on the Compute nodes to store temporary tables that it needs in the course of performing SQL Server operations. |
| 40 | + |
| 41 | +SQL Server PDW drops tables from **tempdb** when: |
| 42 | + |
| 43 | +- The DROP TABLE statement is executed. |
| 44 | + |
| 45 | +- A session is disconnected. Only temporary tables for the session are dropped. |
| 46 | + |
| 47 | +- The appliance is shutdown. |
| 48 | + |
| 49 | +- The Control node has a cluster failover. |
| 50 | + |
| 51 | +## General Remarks |
| 52 | +SQL Server PDW performs the same operations on temporary tables and permanent tables unless explicitly stated otherwise. For example, the data in local temporary tables, just like permanent tables, is either distributed or replicated across the Compute nodes. |
| 53 | + |
| 54 | +## <a name="LimitationsRestrictions"></a>Limitations and Restrictions |
| 55 | +Limitations and restrictions on the SQL Server PDW**tempdb** database. You *cannot:* |
| 56 | + |
| 57 | +- Create a global temporary table that begins with ##. |
| 58 | + |
| 59 | +- Perform a backup or restore of **tempdb**. |
| 60 | + |
| 61 | +- Modify permissions to **tempdb** with the **GRANT**, **DENY**, or **REVOKE** statements. |
| 62 | + |
| 63 | +- Execute **DBCC SHRINKLOG** for **tempdb**tempdb. |
| 64 | + |
| 65 | +- Perform DDL operations on **tempdb**. There are a couple exceptions to this. For details, see the following list of limitations and restrictions on local temporary tables. |
| 66 | + |
| 67 | +Limitations and restrictions on local temporary tables. You *cannot:* |
| 68 | + |
| 69 | +- Rename a temporary table |
| 70 | + |
| 71 | +- Create partitions, views, or non-clustered indexes on a temporary table. **ALTER INDEX** can be used to rebuild a clustered index for a table created with one. |
| 72 | + |
| 73 | +- Modify permissions to temporary tables with the GRANT, DENY, or REVOKE statements. |
| 74 | + |
| 75 | +- Run database console commands on temporary tables. |
| 76 | + |
| 77 | +- Use the same name for two or more temporary tables within the same batch. If more than one local temporary table is used within a batch, each must have a unique name. If multiple sessions are running the same batch and creating the same local temporary table, SQL Server PDW internally appends a numeric suffix to the local temporary table name to maintain a unique name for each local temporary table. |
| 78 | + |
| 79 | +> [!NOTE] |
| 80 | +> You *can* create and update statistics on a temporary table.**ALTER INDEX** can be used to rebuild a clustered index. |
| 81 | + |
| 82 | +## Permissions |
| 83 | +Any user can create temporary objects in tempdb. Users can only access their own objects, unless they receive additional permissions. It is possible to revoke the connect permission to tempdb to prevent a user from using tempdb, but this is not recommended as some routine operations require the use of tempdb. |
| 84 | + |
| 85 | +## <a name="RelatedTasks"></a>Related Tasks |
| 86 | + |
| 87 | +|Tasks|Description| |
| 88 | +|---------|---------------| |
| 89 | +|Create a table in **tempdb**.|You can create a user temporary table with the CREATE TABLE and CREATE TABLE AS SELECT statements. For more information, see [CREATE TABLE](../t-sql/statements/create-table-azure-sql-data-warehouse.md) and [CREATE TABLE AS SELECT](../t-sql/statements/create-table-as-select-azure-sql-data-warehouse.md).| |
| 90 | +|View a list of existing tables in **tempdb**.|`SELECT * FROM tempdb.sys.tables;`| |
| 91 | +|View a list of existing columns in **tempdb**.|`SELECT * FROM tempdb.sys.columns;`| |
| 92 | +|View a list of existing objects in **tempdb**.|`SELECT * FROM tempdb.sys.objects;`| |
| 93 | + |
| 94 | +<!-- MISSING LINKS |
| 95 | +## See Also |
| 96 | +[Common Metadata Query Examples (SQL Server PDW)](../sqlpdw/common-metadata-query-examples-sql-server-pdw.md) |
| 97 | +--> |
| 98 | + |
0 commit comments