very simple predicament I am in.
Basically I have four tables with primary/foreign keys and cascade constraints something like this.
CREATE TABLE [Board]
(
[BoardId] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED ( [BoardId] )
,[Name] [nvarchar](100) NOT NULL
,[Description] [nvarchar](max) NULL
,[PortalId] [int] NOT NULL FOREIGN KEY ( [PortalId] ) REFERENCES Portals ( [PortalID] ) ON DELETE CASCADE ON UPDATE CASCADE
,[OrganizerId] [int] NOT NULL
,[GroupId] [int] NULL
,[ModuleId] [int] NOT NULL FOREIGN KEY ( [ModuleId] ) REFERENCES Modules ( [ModuleID] ) ON DELETE CASCADE ON UPDATE CASCADE
,[CreatedByUserId] [int] NOT NULL
,[CreatedOnDate] [datetime] NOT NULL
,[LastModifiedByUserId] [int] NULL
,[LastModifiedOnDate] [datetime] NULL
)
GO
It has come to a point where I need to rename the original tables. I have renamed tables in the past using sp_rename oldTableName, newTableName
but not tables with primary, foreign, and cascade constraints.
Is it safe enough to rename tables with sp_rename
or should I resort to creating tables from scratch, copying data across and then dropping old tables?