1#include "catch.hpp"
2#include "test_helpers.hpp"
3
4using namespace duckdb;
5using namespace std;
6
7TEST_CASE("Test IF NOT EXISTS", "[create]") {
8 unique_ptr<QueryResult> result;
9 DuckDB db(nullptr);
10 Connection con(db);
11
12 // CREATE TABLE IF NOT EXISTS
13 REQUIRE_NO_FAIL(con.Query("CREATE TABLE IF NOT EXISTS integers(i INTEGER, j INTEGER)"));
14 REQUIRE_NO_FAIL(con.Query("CREATE TABLE IF NOT EXISTS integers(i INTEGER, j INTEGER)"));
15
16 // IF NOT EXISTS with CREATE TABLE AS
17 REQUIRE_NO_FAIL(con.Query("CREATE TABLE IF NOT EXISTS integers2 AS SELECT 42"));
18 REQUIRE_NO_FAIL(con.Query("CREATE TABLE IF NOT EXISTS integers2 AS SELECT 42"));
19
20 // DROP TABLE IF EXISTS
21 REQUIRE_NO_FAIL(con.Query("DROP TABLE IF EXISTS integers"));
22 REQUIRE_NO_FAIL(con.Query("DROP TABLE IF EXISTS integers"));
23}
24