How to extract table names from a SQL query

Posted on 2009-04-17
Last Modified: 2013-11-23
Hi all,

I have a list of SQL query given in a text file.
The text file has to be read line by line and the table names have to be extracted and saved in a csv file.

Is there any way to extract the table names?

Thank you!

Question by:Fionageo
    LVL 86

    Expert Comment

    You'd need a sql parser to do that. Try googling on the two words
    LVL 92

    Accepted Solution

    use the following to reqad the file

    and try this to parse the lines

    LVL 10

    Expert Comment

    by:Pramod Kumar
                Connection con = DriverManager.getConnection("","","");
                Statement st = con.createStatement();
                ResultSet rs = st.executeQuery(".........");
                String tableName = rs.getMetaData().getTableName(1);

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    hash value 2 29
    copyEndy  challenge 15 40
    JVM encoding. How to change encoding. 27 55
    java  and programming certification ? 4 33
    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now