7

How do I create a view only if it doesn't exist. If it does exist, I want to drop the view and redefine it. I also want no warnings or errors.

Alexander Bird
  • 38,679
  • 42
  • 124
  • 159

2 Answers2

21

You're going to kick yourself:

CREATE OR REPLACE VIEW ...

Details here. ;-)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
2
CREATE OR REPLACE VIEW <view name>
AS
<your select expression goes here>
Roland Bouman
  • 31,125
  • 6
  • 66
  • 67