Search in sources :

Example 1 with OracleLobStorageClause

use of com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause in project druid by alibaba.

the class OracleCreateTableParser method parseCrateTable.

public OracleCreateTableStatement parseCrateTable(boolean acceptCreate) {
    OracleCreateTableStatement stmt = (OracleCreateTableStatement) super.parseCrateTable(acceptCreate);
    for (; ; ) {
        if (lexer.token() == Token.TABLESPACE) {
            lexer.nextToken();
            stmt.setTablespace(this.exprParser.name());
            continue;
        } else if (identifierEquals("IN_MEMORY_METADATA")) {
            lexer.nextToken();
            stmt.setInMemoryMetadata(true);
            continue;
        } else if (identifierEquals("CURSOR_SPECIFIC_SEGMENT")) {
            lexer.nextToken();
            stmt.setCursorSpecificSegment(true);
            continue;
        } else if (identifierEquals("NOPARALLEL")) {
            lexer.nextToken();
            stmt.setParallel(false);
            continue;
        } else if (lexer.token() == Token.LOGGING) {
            lexer.nextToken();
            stmt.setLogging(Boolean.TRUE);
            continue;
        } else if (lexer.token() == Token.CACHE) {
            lexer.nextToken();
            stmt.setCache(Boolean.TRUE);
            continue;
        } else if (lexer.token() == Token.NOCACHE) {
            lexer.nextToken();
            stmt.setCache(Boolean.FALSE);
            continue;
        } else if (lexer.token() == Token.NOCOMPRESS) {
            lexer.nextToken();
            stmt.setCompress(Boolean.FALSE);
            continue;
        } else if (lexer.token() == Token.ON) {
            lexer.nextToken();
            accept(Token.COMMIT);
            stmt.setOnCommit(true);
            continue;
        } else if (identifierEquals("PRESERVE")) {
            lexer.nextToken();
            acceptIdentifier("ROWS");
            stmt.setPreserveRows(true);
            continue;
        } else if (identifierEquals("STORAGE")) {
            OracleStorageClause storage = ((OracleExprParser) this.exprParser).parseStorage();
            stmt.setStorage(storage);
            continue;
        } else if (identifierEquals("organization")) {
            lexer.nextToken();
            accept(Token.INDEX);
            stmt.setOrganizationIndex(true);
            continue;
        } else if (lexer.token() == Token.PCTFREE) {
            lexer.nextToken();
            stmt.setPtcfree(this.exprParser.expr());
            continue;
        } else if (identifierEquals("PCTUSED")) {
            lexer.nextToken();
            stmt.setPctused(this.exprParser.expr());
            continue;
        } else if (lexer.token() == Token.STORAGE) {
            OracleStorageClause storage = ((OracleExprParser) this.exprParser).parseStorage();
            stmt.setStorage(storage);
            continue;
        } else if (lexer.token() == Token.LOB) {
            OracleLobStorageClause lobStorage = ((OracleExprParser) this.exprParser).parseLobStorage();
            stmt.setLobStorage(lobStorage);
            continue;
        } else if (lexer.token() == Token.INITRANS) {
            lexer.nextToken();
            stmt.setInitrans(this.exprParser.expr());
            continue;
        } else if (lexer.token() == Token.MAXTRANS) {
            lexer.nextToken();
            stmt.setMaxtrans(this.exprParser.expr());
            continue;
        } else if (lexer.token() == Token.SEGMENT) {
            lexer.nextToken();
            accept(Token.CREATION);
            if (lexer.token() == Token.IMMEDIATE) {
                lexer.nextToken();
                stmt.setDeferredSegmentCreation(DeferredSegmentCreation.IMMEDIATE);
            } else {
                accept(Token.DEFERRED);
                stmt.setDeferredSegmentCreation(DeferredSegmentCreation.DEFERRED);
            }
            continue;
        } else if (identifierEquals("PARTITION")) {
            lexer.nextToken();
            accept(Token.BY);
            if (identifierEquals("RANGE")) {
                SQLPartitionByRange partitionByRange = partitionByRange();
                partitionClauseRest(partitionByRange);
                stmt.setPartitioning(partitionByRange);
                continue;
            } else if (identifierEquals("HASH")) {
                SQLPartitionByHash partitionByHash = partitionByHash();
                partitionClauseRest(partitionByHash);
                stmt.setPartitioning(partitionByHash);
                continue;
            } else if (identifierEquals("LIST")) {
                SQLPartitionByList partitionByList = partitionByList();
                partitionClauseRest(partitionByList);
                stmt.setPartitioning(partitionByList);
                continue;
            } else {
                throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
            }
        }
        break;
    }
    if (lexer.token() == Token.AS) {
        lexer.nextToken();
        OracleSelect select = new OracleSelectParser(exprParser).select();
        stmt.setSelect(select);
    }
    return stmt;
}
Also used : OracleLobStorageClause(com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause) ParserException(com.alibaba.druid.sql.parser.ParserException) OracleSelect(com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect) OracleStorageClause(com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleStorageClause) SQLPartitionByRange(com.alibaba.druid.sql.ast.SQLPartitionByRange) SQLPartitionByHash(com.alibaba.druid.sql.ast.SQLPartitionByHash) OracleCreateTableStatement(com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleCreateTableStatement) SQLPartitionByList(com.alibaba.druid.sql.ast.SQLPartitionByList)

Example 2 with OracleLobStorageClause

use of com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause in project druid by alibaba.

the class OracleExprParser method parseLobStorage.

public OracleLobStorageClause parseLobStorage() {
    lexer.nextToken();
    OracleLobStorageClause clause = new OracleLobStorageClause();
    accept(Token.LPAREN);
    this.names(clause.getItems());
    accept(Token.RPAREN);
    accept(Token.STORE);
    accept(Token.AS);
    for (; ; ) {
        if (identifierEquals("SECUREFILE")) {
            lexer.nextToken();
            clause.setSecureFile(true);
            continue;
        }
        if (identifierEquals("BASICFILE")) {
            lexer.nextToken();
            clause.setBasicFile(true);
            continue;
        }
        if (lexer.token() == Token.LPAREN) {
            lexer.nextToken();
            for (; ; ) {
                if (lexer.token() == Token.TABLESPACE) {
                    lexer.nextToken();
                    clause.setTableSpace(this.name());
                    continue;
                }
                if (lexer.token() == Token.ENABLE) {
                    lexer.nextToken();
                    accept(Token.STORAGE);
                    accept(Token.IN);
                    accept(Token.ROW);
                    clause.setEnable(true);
                    continue;
                }
                if (lexer.token() == Token.CHUNK) {
                    lexer.nextToken();
                    clause.setChunk(this.primary());
                    continue;
                }
                if (lexer.token() == Token.NOCACHE) {
                    lexer.nextToken();
                    clause.setCache(false);
                    if (lexer.token() == Token.LOGGING) {
                        lexer.nextToken();
                        clause.setLogging(true);
                    }
                    continue;
                }
                if (lexer.token() == Token.NOCOMPRESS) {
                    lexer.nextToken();
                    clause.setCompress(false);
                    continue;
                }
                if (lexer.token() == Token.KEEP_DUPLICATES) {
                    lexer.nextToken();
                    clause.setKeepDuplicate(true);
                    continue;
                }
                break;
            }
            accept(Token.RPAREN);
        }
        break;
    }
    return clause;
}
Also used : OracleLobStorageClause(com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause)

Aggregations

OracleLobStorageClause (com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause)2 SQLPartitionByHash (com.alibaba.druid.sql.ast.SQLPartitionByHash)1 SQLPartitionByList (com.alibaba.druid.sql.ast.SQLPartitionByList)1 SQLPartitionByRange (com.alibaba.druid.sql.ast.SQLPartitionByRange)1 OracleStorageClause (com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleStorageClause)1 OracleCreateTableStatement (com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleCreateTableStatement)1 OracleSelect (com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect)1 ParserException (com.alibaba.druid.sql.parser.ParserException)1