A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/sql/docs/sqlserver/manage-tempdb below:

Manage a tempdb database | Cloud SQL for SQL Server

Manage a tempdb database

Stay organized with collections Save and categorize content based on your preferences.

MySQL   |  PostgreSQL   |  SQL Server

This page describes management of the tempdb database in Cloud SQL.

The tempdb database is a system database that holds many objects, including temporary tables, stored procedures, and more. In your instances, you can perform common operations on this database.

A tempdb database is recreated each time an instance is restarted. To prevent the loss of user permissions, Cloud SQL provides permissions to the sqlserver user after an instance is restarted.

Overview

The sqlserver user has the ALTER permission for managing the tempdb database options.

For more information about managing this resource, see the tempdb database page.

Manage tempdb files

After you connect to an instance, the sqlserver user can manage the tempdb files.

Number of files

The user has ALTER permission on the tempdb database, which lets them control settings for the number of files and more. Some example operations include the following:

Note: See Physical properties of tempdb in SQL Server, which includes recommendations related to these settings. Review the information about the number of tempdb data files that would correspond to a given number of logical processors. By default, Cloud SQL creates a minimum of eight files for instances that have greater than or equal to eight logical processors. As included in those recommendations, if the number of logical processors is fewer than or equal to eight, the number of files created is equal to the number of logical processors. File size

The following sections describe methods used to control the size of files in the tempdb database.

For more information about these methods, see Shrink the tempdb database.

Change file sizes in tempdb

To control the size of files in the tempdb database, use the ALTER DATABASE statement. For more information, see ALTER DATABASE (Transact-SQL) File and Filegroup Options.

Shrink individual file size

msdb.dbo.gcloudsql_tempdb_shrinkfile is a stored procedure you can use to shrink an individual file in the tempdb database.

This stored procedure provides all the same benefits of the DBCC SHRINKFILE command.

Caution: Avoid using shrinkfile operations as a part of regular maintenance; only use when necessary. For more information, see DBCC SHRINKFILE documentation.

The following are example uses of the msdb.dbo.gcloudsql_tempdb_shrinkfile stored procedure and its parameters, executed from the Cloud SQL Studio:

  1. Default option

    msdb.dbo.gcloudsql_tempdb_shrinkfile @filename = 'FILENAME'

    Where:

    This command executes the following SQL Server commands:

  2. EMPTYFILE

    msdb.dbo.gcloudsql_tempdb_shrinkfile @filename = 'FILENAME', @empty_file=EMPTY_FILE_INT

    Where:

    This command executes the following SQL Server commands:

  3. Target size

    msdb.dbo.gcloudsql_tempdb_shrinkfile @filename = 'FILENAME', @target_size=TARGET_SIZE_INT

    Where:

    This command executes the following SQL Server commands. The integer 10 is included as an example:

  4. Target size and truncate only

    msdb.dbo.gcloudsql_tempdb_shrinkfile @filename = 'FILENAME', @target_size=10, @truncateonly=TRUNCATE_ONLY_INT

    Where:

    This command executes the following SQL Server commands:

  5. Target size and no truncate option

    msdb.dbo.gcloudsql_tempdb_shrinkfile @filename = 'FILENAME', @target_size=10, @no_truncate=NO_TRUNCATE_INT

    Where:

    This command executes the following SQL Server commands:

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4