Questions tagged [table-rename]

Table renaming is an option in SQL used to rename tables. It is a part of DDL (Data Definition Language).

Table renaming is an option in SQL used to rename tables. It is a part of DDL (Data Definition Language).

Renaming a table can be done in various ways:

RENAME old_table_name TO new_table_name

works only in the same schema while

ALTER TABLE schema.old_table_name RENAME TO new_table_name

can be used on tables in other schemas.

47 questions
350
votes
17 answers

Rename a table in MySQL

Renaming a table is not working in MySQL RENAME TABLE group TO member; The error message is #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group…
Anil Olakkal
  • 3,734
  • 2
  • 17
  • 17
66
votes
5 answers

Rename Oracle Table or View

What is the syntax to rename a table or view in Oracle?
Steven
  • 13,501
  • 27
  • 102
  • 146
52
votes
1 answer

Renaming multiple columns in one statement with PostgreSQL

Is it possible to rename multiple columns in a single statement, something along the lines of: ALTER TABLE Users RENAME COLUMN userName TO user_name, RENAME COLUMN realName TO real_name;
Rovanion
  • 4,382
  • 3
  • 29
  • 49
41
votes
3 answers

Determine Which Objects Reference a Table in SQL Server

I need to rename a table that has many columns and stored procedures that process against that table. How can one get all Items in database that have a relation to a table in such a scenario?
Tavousi
  • 14,848
  • 18
  • 51
  • 70
12
votes
2 answers

Oracle - drop table constraints without dropping tables

I'm doing some bulk migration of a large Oracle database. The first step of this involves renaming a whole load of tables as a preparation for dropping them later (but I need to keep the data in them around for now). Any foreign key constraints on…
Submonoid
  • 2,809
  • 2
  • 20
  • 25
10
votes
2 answers

sql:need to change constraint on rename table?

i have change name of table through procedure sp_rename.Do i need to change fk constraint of child table?
Maddy.Shik
  • 6,609
  • 18
  • 69
  • 98
7
votes
1 answer

Renaming postgres table will drop existing indexes?

I am working on an ETL where we get data from hive and dump it to Postgres. Just to ensure the data is not corrupt I first store the data in a temp table (created as the main table with all the indexes and constraints) and if the data is validated…
raizsh
  • 456
  • 1
  • 6
  • 16
6
votes
2 answers

How do I rename a model with Django?

Let's say I have this model: class Foo(models.Model): name = models.CharField(max_length=255) I want to rename it to Bar. What steps should I take? And how do I deal with The following content types are stale prompt?
x-yuri
  • 16,722
  • 15
  • 114
  • 161
6
votes
3 answers

Changing Oracle table name

I'm trying to change a table name in oracle. I first run this script to declare the table CREATE TABLE CUSTOMER ( C_ID NUMBER(6,0), C_LAST VARCHAR2(25), C_FIRST varchar2(25), C_MI char(1), C_DOB DATE, C_ADDRESS varchar2(100), C_CITY…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
5
votes
2 answers

Oracle: Rename column gives "ORA-00903: invalid table name" error even when no constraint or index is there

RENAME COLUMN table-Name.simple-Column-Name TO simple-Column-Name When i try to rename column i am getting following error message on all columns: RENAME COLUMN EMP_NEW.EMPLOYEE_ID TO EMPLOYEEID Error report - ORA-00903: invalid table name 00903.…
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
5
votes
1 answer

what is the difference between 'alter table rename' and 'rename table'?

I am using MySQL. Here's an example, I want to rename a table A to B, so what's the difference between following statement: alter table A rename to B; and this one: rename table A to B; Can anyone give a detail compare between them? Is it vary…
Suanmeiguo
  • 1,365
  • 3
  • 17
  • 28
4
votes
1 answer

I can't rename a mysql table name... it has a space in it

I've imported a csv into MySQL. PHPMyAdmin helpfully created a table called TABLE 8 (with a space). When I try to rename in SQL: RENAME TABLE 8 to gender I get the error: #1064 - You have an error in your SQL syntax; check the manual that…
stilts77
  • 191
  • 3
  • 14
4
votes
2 answers

Renaming a table while leaving the existing triggers behind

A decision was made to join a couple of existing tables together in a cluster. This obviously means that the tables need to be recreated so they can be clustered together, however the existing data should be preserved. Naturally I assume the…
Ceiling Gecko
  • 3,104
  • 2
  • 24
  • 33
4
votes
2 answers

How can I rename a table in MonetDB?

How can I rename a table in monetdb? The typical SQL statement ALTER TABLE name RENAME TO new_name is not supported.
pic
  • 41
  • 2
3
votes
2 answers

Renaming database that has tables with triggers

I need to rename my database and figured out that by creating new DB and renaming the tables to new DB name, it is possible to rename DB I followed the Renaming Tables with InnoDB section of…
1
2 3 4