Convert AsciiDoc to SQL

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

AsciiDoc vs SQL Format Comparison

Aspect AsciiDoc (Source Format) SQL (Target Format)
Format Overview
AsciiDoc
Lightweight Markup Language

A lightweight markup language created by Stuart Rackham in 2002 for writing technical documentation. AsciiDoc offers rich semantic markup for creating structured documents that can be processed into HTML, PDF, EPUB, and other formats. Widely adopted in open-source projects and enterprise documentation.

Plain Text Technical Docs
SQL
Structured Query Language

A domain-specific language designed for managing and querying relational databases. SQL files contain statements for creating tables, inserting data, updating records, and querying information. Standardized by ANSI/ISO with vendor-specific extensions for MySQL, PostgreSQL, Oracle, SQL Server, and SQLite.

Database Query Language
Technical Specifications
Structure: Plain text with semantic markup
Encoding: UTF-8 text
Format: Human-readable markup
Compression: None (plain text)
Extensions: .adoc, .asciidoc, .asc
Structure: Declarative statements with semicolons
Encoding: UTF-8 / ASCII text
Format: Structured query statements
Compression: None (plain text)
Extensions: .sql
Syntax Examples

AsciiDoc data table:

= User Database Schema

|===
| Column | Type | Description

| id | INTEGER | Primary key
| name | VARCHAR | User name
| email | VARCHAR | Email address
| created | TIMESTAMP | Creation date
|===

SQL table creation and insert:

CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  name VARCHAR(255),
  email VARCHAR(255),
  created TIMESTAMP DEFAULT NOW()
);

INSERT INTO users (name, email)
VALUES ('John', '[email protected]');
Content Support
  • Section headings and hierarchy
  • Rich text formatting
  • Data tables with headers
  • Source code blocks
  • Admonition blocks
  • Cross-references and links
  • Include directives
  • Document attributes
  • Images and media
  • DDL: CREATE, ALTER, DROP statements
  • DML: SELECT, INSERT, UPDATE, DELETE
  • DCL: GRANT, REVOKE permissions
  • Transaction control (BEGIN, COMMIT)
  • Views, indexes, constraints
  • Stored procedures and functions
  • Comments (-- and /* */)
Advantages
  • Rich semantic documentation format
  • Multi-format output capability
  • Version control friendly
  • Modular documentation support
  • Strong tooling (Asciidoctor)
  • Ideal for documenting database schemas
  • Universal database language
  • Standardized (ANSI/ISO SQL)
  • Directly executable in databases
  • Human-readable query syntax
  • Powerful data manipulation
  • Version control compatible
  • Supports complex data operations
Disadvantages
  • Requires processing tools for output
  • Not directly executable
  • Smaller community than Markdown
  • Complex syntax for advanced features
  • Not a data interchange format
  • Vendor-specific dialect differences
  • No built-in document formatting
  • Requires database engine to execute
  • Limited to relational data models
  • Security risks (SQL injection)
  • Complex joins can be hard to read
Common Uses
  • Technical documentation
  • Database schema documentation
  • Architecture decision records
  • Software manuals and guides
  • Book authoring
  • Database schema definitions
  • Data migration scripts
  • Seed data and test fixtures
  • Database backups (mysqldump)
  • Reporting and analytics queries
  • Application database initialization
Best For
  • Documenting database designs
  • Writing data dictionaries
  • Schema reference manuals
  • Technical specification documents
  • Database creation and management
  • Data import and migration
  • Automated deployment scripts
  • Reproducible database setups
Version History
Introduced: 2002 (Stuart Rackham)
Current Implementation: Asciidoctor (Ruby, 2013+)
Status: Actively developed
Evolution: AsciiDoc to Asciidoctor migration
Introduced: 1974 (IBM SEQUEL), standardized 1986
Current Standard: SQL:2023 (ISO/IEC 9075)
Status: Actively standardized and developed
Evolution: Regular ISO standard updates
Software Support
Asciidoctor: Full support (Ruby, JS, Java)
IDE Support: IntelliJ, VS Code, Eclipse plugins
CI/CD: GitHub, GitLab rendering
Other: Antora, docToolchain, Maven plugins
MySQL/MariaDB: Full SQL support
PostgreSQL: Advanced SQL with extensions
SQLite: Lightweight embedded SQL
Other: Oracle, SQL Server, DBeaver, pgAdmin

Why Convert AsciiDoc to SQL?

Converting AsciiDoc to SQL is valuable when you need to transform documented database schemas, data specifications, or tabular content from technical documentation into executable SQL statements. AsciiDoc is commonly used to document database designs, data dictionaries, and migration plans, and converting this documentation directly to SQL eliminates the manual step of translating documented specifications into database scripts.

AsciiDoc tables are particularly well-suited for describing database schemas -- columns typically represent field names, data types, constraints, and descriptions. The conversion process interprets these documented structures and generates corresponding CREATE TABLE statements, INSERT operations for sample data, and appropriate constraints. This approach ensures that the implemented database schema matches the documented specification exactly.

SQL, or Structured Query Language, has been the standard language for relational database management since its standardization by ANSI in 1986. Modern SQL supports complex data operations including transactions, stored procedures, views, and advanced querying. By converting documentation to SQL, teams can rapidly prototype database structures, generate seed data scripts, and create migration files that are immediately executable in database management systems like MySQL, PostgreSQL, SQLite, and Oracle.

This conversion is especially useful in agile development workflows where database documentation and implementation need to stay synchronized. Rather than maintaining separate documentation and SQL files that can drift apart, teams can author their schema documentation in AsciiDoc and generate SQL scripts automatically. This documentation-as-code approach reduces errors, speeds up development, and ensures that database changes are properly documented.

Key Benefits of Converting AsciiDoc to SQL:

  • Schema Generation: Create database tables directly from documented specifications
  • Data Migration: Generate INSERT statements from documented data tables
  • Documentation Sync: Keep database schemas aligned with technical documentation
  • Rapid Prototyping: Quickly set up databases from design documents
  • Cross-Database: Generate standard SQL compatible with multiple database engines
  • Seed Data: Convert sample data tables into executable INSERT scripts
  • Reproducible: Create repeatable database setup scripts from documentation

Practical Examples

Example 1: Database Schema Documentation

Input AsciiDoc file (schema.adoc):

= E-Commerce Database Schema

== Products Table

|===
| Column | Type | Constraints

| product_id | SERIAL | PRIMARY KEY
| name | VARCHAR(200) | NOT NULL
| price | DECIMAL(10,2) | NOT NULL
| category | VARCHAR(100) | DEFAULT 'general'
| stock | INTEGER | DEFAULT 0
|===

== Orders Table

|===
| Column | Type | Constraints

| order_id | SERIAL | PRIMARY KEY
| user_id | INTEGER | REFERENCES users(id)
| total | DECIMAL(10,2) | NOT NULL
| status | VARCHAR(50) | DEFAULT 'pending'
|===

Output SQL file (schema.sql):

-- E-Commerce Database Schema

-- Products Table
CREATE TABLE products (
    product_id SERIAL PRIMARY KEY,
    name VARCHAR(200) NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    category VARCHAR(100) DEFAULT 'general',
    stock INTEGER DEFAULT 0
);

-- Orders Table
CREATE TABLE orders (
    order_id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id),
    total DECIMAL(10,2) NOT NULL,
    status VARCHAR(50) DEFAULT 'pending'
);

Example 2: Sample Data Documentation

Input AsciiDoc file (seed-data.adoc):

= Test Data for Development

== Sample Users

|===
| name | email | role

| Alice Johnson | [email protected] | admin
| Bob Smith | [email protected] | editor
| Carol White | [email protected] | viewer
|===

== Sample Categories

|===
| name | description

| Electronics | Phones, laptops, tablets
| Books | Physical and digital books
| Clothing | Apparel and accessories
|===

Output SQL file (seed-data.sql):

-- Test Data for Development

-- Sample Users
INSERT INTO users (name, email, role) VALUES
('Alice Johnson', '[email protected]', 'admin'),
('Bob Smith', '[email protected]', 'editor'),
('Carol White', '[email protected]', 'viewer');

-- Sample Categories
INSERT INTO categories (name, description) VALUES
('Electronics', 'Phones, laptops, tablets'),
('Books', 'Physical and digital books'),
('Clothing', 'Apparel and accessories');

Example 3: Migration Plan Documentation

Input AsciiDoc file (migration.adoc):

= Database Migration v2.0

== New Columns

Add the following columns to the users table:

* `phone` VARCHAR(20) -- optional phone number
* `avatar_url` TEXT -- profile picture URL
* `last_login` TIMESTAMP -- last login time

== Index Requirements

Create indexes for frequently queried columns:

* users.email (unique)
* orders.user_id (non-unique)
* products.category (non-unique)

Output SQL file (migration.sql):

-- Database Migration v2.0

-- New Columns
ALTER TABLE users ADD COLUMN phone VARCHAR(20);
ALTER TABLE users ADD COLUMN avatar_url TEXT;
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;

-- Index Requirements
CREATE UNIQUE INDEX idx_users_email ON users(email);
CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE INDEX idx_products_category ON products(category);

Frequently Asked Questions (FAQ)

Q: What kind of SQL is generated from AsciiDoc?

A: The converter generates standard ANSI SQL that is compatible with most relational database systems. The output includes CREATE TABLE statements from schema tables, INSERT statements from data tables, and comments from document headings. The SQL follows standard syntax conventions and can be executed in MySQL, PostgreSQL, SQLite, SQL Server, and Oracle with minimal or no modifications.

Q: How does the converter handle AsciiDoc tables?

A: AsciiDoc tables are the primary source of structured data for SQL generation. Tables with column headers like "Column, Type, Constraints" are interpreted as schema definitions and generate CREATE TABLE statements. Tables with data-like content generate INSERT statements. The converter analyzes header row patterns to determine the appropriate SQL output type automatically.

Q: Can I specify the target database dialect?

A: The default output uses standard ANSI SQL for maximum compatibility. Database-specific features like SERIAL (PostgreSQL), AUTO_INCREMENT (MySQL), or AUTOINCREMENT (SQLite) depend on the data types documented in your AsciiDoc source. If your documentation uses vendor-specific syntax, those constructs are preserved in the SQL output. For cross-database compatibility, use standard SQL data types in your documentation.

Q: What happens to non-table content in the AsciiDoc file?

A: Section headings are converted to SQL comment blocks (-- Section Name) to maintain document structure. Descriptive paragraphs become multi-line SQL comments (/* ... */). Lists describing schema changes may be converted to ALTER TABLE or CREATE INDEX statements when the content follows recognizable patterns. Code blocks containing SQL examples are extracted and included directly.

Q: Is the generated SQL safe to run directly?

A: The generated SQL should be reviewed before execution on production databases. It is designed for development, testing, and prototyping purposes. Always test generated SQL in a development environment first. The converter does not add DROP TABLE or DELETE statements unless explicitly present in the source documentation. Use transactions (BEGIN/COMMIT) when running generated migration scripts.

Q: Can the converter handle complex AsciiDoc documents?

A: Yes. The converter processes multi-section documents with multiple tables, extracting SQL-relevant content from each section. Include directives are resolved, and nested document structures are flattened appropriately. Admonition blocks (NOTE, WARNING) are converted to SQL comments. Cross-references are resolved to their target content. The converter focuses on extracting actionable database operations from the documentation.

Q: How are AsciiDoc code blocks with SQL handled?

A: AsciiDoc source blocks marked with [source,sql] are extracted and included directly in the output without modification. This means if your documentation already contains SQL examples, those exact statements appear in the converted file. This is particularly useful for documentation that includes migration scripts, query examples, or stored procedure definitions alongside explanatory text.

Q: Can I convert SQL back to AsciiDoc?

A: Yes, our converter supports SQL to AsciiDoc conversion. The reverse process parses SQL statements and generates structured AsciiDoc documentation with tables describing schema definitions, formatted code blocks for complex queries, and organized sections based on SQL comment blocks. This is useful for generating database documentation from existing SQL scripts or database dumps.