Ryan Clark
Ryan Clark

Reputation: 764

Remove external file from postgresql

I added a file to postgres using \i /path/to/some/file.sql but there was a typo in the file.

Here's what I had in the file:

CREATE VIEW holidays AS
  SELECT event_id AS holiday_id, title AS name, starts AS date
  FROM events
  WHERE title LIKE '%Day%' AND venue_id IS NULL;

In the original version I had %DAY%. When running \i /path/to/some/file.sql again, I receive this error:

ERROR:  relation "holidays" already exists

How do I undo this relation to get the code to run again?

Thanks

Upvotes: 1

Views: 339

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53533

The \i command does not "add a file" that can later be removed. It simply runs the SQL within the file, as if you had typed it at the psql command prompt. If you want to undo what you did, it will depend on what exactly the SQL was.

Upvotes: 1

Related Questions