This tag is for renaming database, DBMS instances and database objects (such as tables, views, columns, etc.)
Questions tagged [rename]
15 questions
5
votes
2 answers
How can I safely rename a sequence in PostgreSQL, ideally without downtime?
We want to rename some sequences in our production database for certain reasons.
Is there a way to do this safely in production without having to first close all connections to the database?
It's fine if we get gaps in the ID sequence (e.g. it jumps…
Henrik N
- 197
- 1
- 7
3
votes
1 answer
Will renaming a MySQL table to another database result in a full table copy operation on disk?
I understand that renaming a table within the same database will not generally result in a table copy... It's not clear to me if this holds true for renaming across databases.
For reference, I want to move/rename a ~1TB table to a different…
Dan
- 235
- 2
- 11
2
votes
1 answer
Seamless SQLServer Database Name Change
I need to change the name for a few databases, however the databases are used by a lot of applications managed by several different teams. It would take some time for all the applications to finish changing connections and database name references.…
JieLong
- 315
- 1
- 9
2
votes
3 answers
Is it good practice to refer to a table with different names in a database schema?
We have a database currently running with a table named a certain way (let's say thing for the sake of example), and references to that table named the same way (FK would be named thing_id for instance).
We also used to have this thing concept in…
Aweb
- 21
- 2
2
votes
0 answers
Rename table in Postgres and update its usages in all functions
I need to safely rename a table and be sure, that all usages of this table in functions are also renamed.
Example:
CREATE TABLE test (
id serial,
name varchar(255)
);
CREATE FUNCTION public.last_test() RETURNS SETOF test
LANGUAGE sql…
AntonAL
- 121
- 4
1
vote
2 answers
Are extra unused columns helpful in future?
Currently, while creating tables, we create 4 to 5 extra columns with temp names like c0, c1, c2 etc. to be used later when needed and are left NULL by default.
This way we don't have to create additional columns when needed. We just rename one of…
Bhupendra Pandey
- 13
- 4
1
vote
2 answers
How to rename a column name which has been created by a math function in mysql? Using ALTER TABLE is giving ERROR: 1064 (42000)
INPUT:
CREATE TABLE dist
-> SELECT ST_DISTANCE(POINT(x1,y1),POINT(x2,y2))
-> FROM config;
OUTPUT:
+------------------------------------------+
| ST_DISTANCE(POINT(x1,y1) , POINT(x2,y2)) |
+------------------------------------------+
| …
Titiksha
- 13
- 2
1
vote
1 answer
SQL Server and TFS - How to rename stored procedures
After a while one may wish to do some light refactoring, such as giving more appropriate names to stored procedures as their functionalities are better established.
For the life of me, I simply cannot rename anything in SQL in a multi-branch TFS…
Elaskanator
- 761
- 2
- 9
- 23
0
votes
2 answers
How to rename hostname in a Mongodb replica set
I need to know how I can rename my hosts belonging to my replica environment in mongodb, I currently have the following configuration:
rs.conf()
{
"_id" : "myreplicaset01",
"version" : 3,
"term" : 22,
…
miguel ramires
- 169
- 1
- 5
- 18
0
votes
1 answer
best and quickest way to rename the primary key of a table
when I need to rename a table and consequently its primary key (and all other constraints) as well I use the following simple example script:
if object_id('dbo.Radhe1',N'U') is not null
drop table dbo.radhe1
create table dbo.Radhe1 (
id int…
Marcello Miorelli
- 17,274
- 53
- 180
- 320
0
votes
4 answers
How to tell Microsoft SQL Server Management Studio that a DB rename must be done completely
I have an older copy of a database. I retrieved it from customer system by taking a backup and restore it on my local PC. I would like to have a look at a more recent copy of that same database. Obviously I cannot do that, working on the same…
Dominique
- 609
- 1
- 7
- 23
0
votes
1 answer
What is the standard SQL way to rename a column?
So far I've seen ALTER TABLE RENAME, ALTER TABLE CHANGE and ALTER TABLE MODIFY.
What I'm trying to achieve is something like ALTER TABLE my_table RENAME col_old_name TO col_new_name, which can be a case of modifying a column.
SQLite goes with…
vesperto
- 135
- 1
- 2
- 8
0
votes
1 answer
Renaming multiple databases on a MySQL slave
I have 4 mysql databases that I'm replicating from a master to a slave. In the past, I have renamed one of them because the slave is also a dev server where it has a dev version of that schema with the same name as prod, to make things easier for…
churnd
- 121
- 3
0
votes
0 answers
renaming Windows machine and SQL Server
We've built a new Windows 2016 VM with SQL Server 2016 that we'll migrate a mission critical database currently on SQL Server 2008 R2 to. The original plan was to have users test, test, test and test each data feed coming in. There is pushback from…
Joe G
- 1
-1
votes
1 answer
How to rename columns in an SQL-server database
My employer has the habit of giving customer specific tables a name, starting with the name of the customer. This makes it difficult to call the sp_rename stored procedure for renaming column names, as you can see:
/*Version 1:*/
sp_rename…
Dominique
- 609
- 1
- 7
- 23