-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/43 implement create drop schema (#44)
* #43: implemented create schema statement * #43: implemented drop schema statement * #43: moved classes into appropriate packages
- Loading branch information
1 parent
3301ba8
commit 9422adc
Showing
72 changed files
with
1,276 additions
and
237 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# CREATE SCHEMA | ||
|
||
The `CreateSchema` class of the SQL Statement Builder provides an entry | ||
point to defining a CREATE SCHEMA SQL statement. | ||
|
||
## Usage | ||
|
||
1. Create an instance of the `CreateSchema` class through the `StatementFactory` | ||
|
||
```java | ||
CreateSchema createSchema = StatementFactory.getInstance().createSchema("schemaName"); | ||
``` | ||
|
||
2. Render the instance of `CreateSchema` class. Click [here](../rendering.md) for more information on Rendering SQL Statement. | ||
|
||
- The complete example code | ||
|
||
```java | ||
CreateSchema createSchema = StatementFactory.getInstance().createSchema("schemaName"); | ||
|
||
//optional step: add config | ||
StringRendererConfig config = StringRendererConfig.builder().lowerCase(true).build(); | ||
CreateSchemaRenderer renderer = CreateSchemaRenderer.create(config); | ||
createSchema.accept(renderer); | ||
|
||
String renderedString = renderer.render(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# DROP SCHEMA | ||
|
||
The `DropSchema` class of the SQL Statement Builder provides an entry | ||
point to defining a DROP SCHEMA SQL statement. | ||
|
||
## Usage | ||
|
||
1. Create an instance of the `DropSchema` class through the `StatementFactory` | ||
|
||
```java | ||
DropSchema dropSchema = StatementFactory.getInstance().dropSchema("schemaName"); | ||
``` | ||
|
||
2. Add available options using fluent programming if necessary. | ||
|
||
The following options are currently supported: | ||
|
||
- `IF EXISTS` | ||
- `CASCADE` | ||
- `RESTRICT` | ||
|
||
Example: | ||
|
||
```java | ||
dropSchema.ifExists().cascade(); | ||
``` | ||
Please do not use methods `cascade()` and `restrict()` on the same object. | ||
If both these options are used on the same object, `IllegalArgumentException` will be thrown. | ||
|
||
3. Render the instance of `DropSchema` class. Click [here](../rendering.md) for more information on Rendering SQL Statement. | ||
|
||
- The complete example code | ||
|
||
```java | ||
DropSchema dropSchema = StatementFactory.getInstance().dropSchema("schemaName"); | ||
|
||
//optional step: add additional clauses | ||
dropSchema.ifExists().cascade(); | ||
//or | ||
dropSchema.ifExists().restrict(); | ||
|
||
//Rendering | ||
//optional step: add config | ||
StringRendererConfig config = StringRendererConfig.builder().lowerCase(true).build(); | ||
|
||
DropSchemaRenderer renderer = DropSchemaRenderer.create(config); | ||
dropSchema.accept(renderer); | ||
String renderedString = renderer.render(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...n/java/com/exasol/sql/dql/ValueTable.java → src/main/java/com/exasol/sql/ValueTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.exasol.sql.ddl; | ||
|
||
import com.exasol.sql.AbstractFragment; | ||
import com.exasol.sql.Fragment; | ||
import com.exasol.sql.ddl.create.CreateSchemaVisitor; | ||
import com.exasol.sql.ddl.drop.DropSchemaVisitor; | ||
|
||
/** | ||
* This class represents a {@link Schema} in an SQL Statement | ||
*/ | ||
public class Schema extends AbstractFragment { | ||
private final String name; | ||
|
||
/** | ||
* Create a new {@link Schema} | ||
* | ||
* @param root SQL statement this schema belongs to | ||
* @param schemaName schema name | ||
*/ | ||
public Schema(final Fragment root, final String schemaName) { | ||
super(root); | ||
this.name = schemaName; | ||
} | ||
|
||
/** | ||
* Get the schema name | ||
* | ||
* @return schema name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void accept(final CreateSchemaVisitor visitor) { | ||
visitor.visit(this); | ||
} | ||
|
||
public void accept(final DropSchemaVisitor visitor) { | ||
visitor.visit(this); | ||
} | ||
} |
Oops, something went wrong.