I have a script that I am running for homework that looks like so:
drop table burger_king_locations_clean;
drop table burger_king_locations_unresolv;
create table burger_king_locations_clean
(
...
);
create table burger_king_locations_unresolv
(
....
);
But when I run this I get the following message and I don't understand because I know the table is gone and there is no view or any other object with that name.
Table dropped.
drop table burger_king_locations_unresolv
*
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
Table created.
create table burger_king_locations_unresolv
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
I don't understand because this exact thing was working before but I put my computer in sleep mode and then came back to this and now it doesn't work at all. Any ideas?
"I have a script that I am running for homework that looks like so"
So you say. But the posted output shows the execution of two DROP statements, one of which fails, and two CREATE statements, one of which is run twice.
Why did the drop table burger_king_locations_unresolv; fail? Who can tell? Perhaps you had already dropped it, perhaps the previous create had failed.
Likewise it is not possible for us to tell you why the create table burger_king_locations_unresolv ran twice. Perhaps your script has a stray back slash following the semi-colon.
Wouldn't you need to purge the table?
drop table burger_king_locations_clean PURGE;
drop table burger_king_locations_unresolv PURGE;
Related
I've been trying to rename a table from "fund performance" to fund_performance in SQLWorkbench for a Redshift database. Commands I have tried are:
alter table schemaname."fund performance"
rename to fund_performance;
I received a message that the command executed successfully, and yet the table name did not change.
I then tried copying the table to rename it that way. I used
#CREATE TABLE fund_performance LIKE "schema_name.fund performance";
CREATE TABLE fund_performance AS SELECT * FROM schema_name."fund performance";
In both these cases I also received a message that the statements executed successfully, but nothing changed. Does anyone have any ideas?
Use following it may work out for you
SELECT * into schema_name.fund_performance FROM schema_name.[fund performance]
It will copy the data by creating new table as fund_performance but it won't create any constraints and Identity's
To Rename specific table without disturbing existing constraints
EXEC sp_rename 'schema_name.[fund performance]', 'schema_name.fund_performance';
Im getting an error at DROP TABLE but I cant figure out why. My table PLAYER_OBJECT is already coded and working but even if the table is created the error on drop table wont go away. What I my doing wrong.
DROP TABLE PLAYER_OBJECT
CREATE TABLE PLAYER_OBJECT()
You could simply put IF EXISTS between TABLE AND PLAYER_OBJECT, like this:
DROP TABLE IF EXITS PLAYER_OBJECT
You problably have an error in the creation of you table or you didnt launch your code.
I'd like to create a script that simply drops and creates a database over and over in PostgreSQL.
For a table this is not problem with the following:
DROP TABLE IF EXISTS test CASCADE;
CREATE TABLE IF NOT EXISTS test ( Sample varchar );
The above code works, no problem.
However, when I try to do the same for a database, ie:
DROP DATABASE IF EXISTS sample;
CREATE DATABASE sample;
I get the following error:
ERROR: DROP DATABASE cannot run inside a transaction block
SQL state: 25001
Any idea how I can get the database to be created and dropped repetitively without doing it manually?
HI I am generating schema script for a database, but when i finish creating it and and look at the script it gives create table statement for a table but not including all column in it also it generates alter table add column statement for the same tables but for missing columns which are left in create table statement.
see the attached screenshot.
Assuming the question is "why does it not create all of the columns in the CREATE TABLE statement" ...
You'll notice that between the CREATE TABLE and the ALTER statements, the value for SET ANSI_PADDING is altered. As the documentation notes, the setting's value is taken into account at the point in time when a column is created.
There's no way to override this setting in-line with the declaration of a column.
Since your table apparently contains a mixture of columns, some of which are defined with the setting ON and others with it defined OFF, there's no way to write a single CREATE TABLE statement that creates all of the columns in one go.
I've got a problem with a database here, in which after one update on the database one table stopped working.
What i can't do (Considering table xxx):
Dump whole database; (it says that the table doesn't exist)
SELECT *
FROM xxx; (it says that the table doesn't exist)
CREATE TABLE xxx(id int); (it says that the table exists)
I can't find any solution on the internet.
The Table Appears when you do a show tables?
mysql> show tables
Have you tried restart the mysql service?