HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

what is '#' in create table statement?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
createtablewhatstatement

Problem

I recently saw a statement like:

CREATE TABLE #tbl_AR_Data


I wanted to know what is the purpose of the symbol # (NUMBER SIGN, hash, pound sign) in this statement?

Solution

'#' denotes a temporary table.

This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When I close this session, the table will be automatically dropped.

You can treat this table just like any other table with a few exceptions. The only real major one is that you can't have foreign key constraints on a temporary table.

Temporary tables are available in MySQL version 3.23 onwards. If you use an older version of MySQL than 3.23, you can't use temporary tables, but you can use heap tables.

Read about usage and syntax here.

Context

StackExchange Database Administrators Q#71242, answer score: 11

Revisions (0)

No revisions yet.