File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/main/java/com/code/advancedsql/query Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ public class Create extends ExecuteStatement<Create> {
1919
2020 private final Action action = new Regular ();
2121
22+ private boolean ifNotExists = false ;
23+
2224 public Create (ITable table ) {
2325 super (table );
2426 }
@@ -315,9 +317,16 @@ public Base column(java.lang.String name, String content) {
315317 return this .action .column (name , content );
316318 }
317319
320+ /**
321+ * Create table if not exists.
322+ */
323+ public void ifNotExists () {
324+ this .ifNotExists = true ;
325+ }
326+
318327 @ Override
319328 public java .lang .String toQuery () {
320- StringBuilder query = new StringBuilder ("CREATE TABLE " + this .table + " ( " );
329+ StringBuilder query = new StringBuilder ("CREATE TABLE " + ( ifNotExists ? "IF NOT EXISTS" : "" ) + this .table + " ( " );
321330
322331 List <IColumn > columns = this .action .getColumns ();
323332
You can’t perform that action at this time.
0 commit comments