Visitar URL original
How to parse CREATE DATABASE DATABASE_NAME ? · Issue #2070 · JSQLParser/JSqlParser · GitHub
Skip to content

How to parse CREATE DATABASE DATABASE_NAME ?  #2070

Description

@ganesh-akashh

package org.example;

import net.sf.jsqlparser.parser.CCJSqlParser;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.Statements;

class Main {

public static void main(String[] args) {
   
    try {
        String sqlStr = "CREATE DATABASE USERS; ";
        Statement statement=CCJSqlParserUtil.parse(sqlStr);


    } catch (Exception e) {
        System.out.println(e.getMessage());
    }


}

}

Activity

  1. manticore-projects commented on Sep 6, 2024

    @manticore-projects
    Contributor

    I just double checked that Grammar: there is indeed no support yet for CREATE DATABASE ...
    PRs are welcome.

  2. ganesh-akashh commented on Sep 9, 2024

    @ganesh-akashh
    Author

    Can you share a user guide on how to introduce new features ?

  3. manticore-projects commented on Sep 9, 2024

    @manticore-projects
    Contributor

    Greetings!

    Can you share a user guide on how to introduce new features ?

    https://manticore-projects.com/JSQLParser/contribution.html

    Cheers!

  4. fudianchn commented on Aug 15, 2026

    @fudianchn
    Contributor

    PR #2471 adds a typed CreateDatabase statement: CREATE DATABASE [IF NOT EXISTS] <name> parses into CreateDatabase (with getDatabaseName()), and vendor-specific options after the name such as MySQL's DEFAULT CHARACTER SET utf8mb4 are captured verbatim and round-trip unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions