---
title: "Oracle - Add Exist Validation Before Create Table"
author: "kylinsoong"
date: "2011-11-07T13:49:00Z"
tags: []
categories: ["数据库"]
slug: "oracle-add-exist-validation-before-create-table"
draft: false
lastmod: "2011-11-07T13:49:00Z"
id: 1238656
url: "https://kylinsoong.iteye.com/blog/1238656"
---

Usually we need to check the table is exist or not before create a new table, In Mysql database, that's very easy, 'cause mysql default sql statement support exist check, But in Oracle it's quite complicated. the following is a solution to validate the table is existable before create it in Oracle Platform:

Assuming APPVersion table already exist in database through the following sql statement:

```
create table AppVersion (
  NAME varchar2(30) primary key not null,
  VERSION varchar2(30) not null,
  INSTALLED DATE not null
);
```

The Following PL/SQL can implement exist validation before create  table APPVersion duplicated:

```
DECLARE
BEGIN   
  EXECUTE IMMEDIATE 'DROP TABLE APPVERSION';
  EXCEPTION WHEN OTHERS THEN NULL;
  COMMIT;
END;
/
```