All Products
Search
Document Center

ApsaraDB RDS:How do I change the table schema to dbo in an RDS for SQL Server instance?

Last Updated:Feb 25, 2025

Problem description

An error indicating that the object name is invalid is prompted when I query data from a table in an RDS for SQL Server instance.

Cause

Execute the following statement to check the table information:

SELECT a.name schemaName,b.name tableName,b.type_desc FROM sys.schemas a , sys.tables b
WHERE a.schema_id = b.schema_id

The result shows that the schema of the table is not dbo, which is the cause of the error.

Solution

  • Change the schema of a single table.

    Sample command:

    ALTER SCHEMA dbo TRANSFER test.kkk
  • Change the schema of multiple tables in a batch.

    Sample command:

    exec sp_msforeachtable 'alter schema dbo transfer ?'