Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7616191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:49:55+00:00 2026-05-31T02:49:55+00:00

In Grails, how can plain SQL/DDL be used to create / drop tables in

  • 0

In Grails, how can plain SQL/DDL be used to create / drop tables in the same manner they would be if one were using GORM / ORM?

For example, when using GORM / ORM, the tables used for persistence are regularly created/dropped, and inserted into, during the runtime of Integration Tests, and execution of the application.

I know there is a way to do this using just Groovy as shown in the example named “Advanced Usage” here, but I’m looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:49:57+00:00Added an answer on May 31, 2026 at 2:49 am

    I’m looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.

    As far as I know, there is no such support built-into Grails, so you’ll have to write it yourself. Luckily it shouldn’t be too difficult. Here’s an implementation plan:

    • Store your DDL file in the conf directory
    • In Bootstrap.groovy, dependency-inject the DataSource Spring bean
    • In the init closure of Bootstrap.groovy use the DataSource to get a Connection to the DB
    • Using the Connection, create the database and execute the SQL statements in the DDL file against it
    • In the destroy closure of Bootstrap.groovy, drop the database
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params)
In Grails I can create domain objects to a H2 in memory dataSource in
Grails provides an isDirty method that can be called on domain objects. How would
I've built a Maven Grails project which can be build fine using command mvn
How can I call a method in one of my controller classes without grails
Can anyone tell me how to create multiple records in grails. This class is
Has anyone used Maven , Grails , and App Engine together? I can use
In a grails controller I can render an image to the response using class
How can I create a simple testing/experimenting file in grails? I tried creating a
I can create a secure, multi-tenant web app with Grails by : setup spring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.