Introducción
Joule puede ayudar a los administradores de bases de datos a escribir consultas SQL comprendiendo las peticiones de lenguaje natural para generar, refinar y explicar consultas. Ayuda a construir consultas complejas y optimizar el rendimiento, mejorando la productividad y reduciendo los errores.
Uso de Joule para escribir consultas SQL
En los siguientes ejemplos de petición, Joule generará código SQL para crear una tabla, generará una sentencia para insertar datos en la tabla creada. Los ejemplos de petición también mostrarán cómo indicar a Joule que cree sentencias SELECT.
Creación y configuración del esquema
1Show the SQL to create a schema called HC200_SCHEMAJoule respondió con el siguiente código:
1CREATE SCHEMA "HC200_SCHEMA";Si desea saber cómo establecer este esquema como esquema predeterminado para utilizar, pregunte a Joule lo siguiente:
1Show the SQL to set the schema to HC200_SCHEMAJoule respondió con el siguiente código:
1SET SCHEMA "HC200_SCHEMA";Crear una tabla e insertar datos
Para obtener el código SQL para crear una tabla en ese esquema, pida a Joule lo siguiente:
1234Show the SQL statement to create a table named HC200_DEMO in the
schema HC200_SCHEMA with the field ProductNumber of the type int, a
field ProductName type string and a field Stock type int. Make
the field ProductNumber the primary key.Joule respondió con el siguiente código:
123456
CREATE COLUMN TABLE "HC200_SCHEMA"."HC200_DEMO" (
"ProductNumber" INT PRIMARY KEY,
"ProductName" NVARCHAR(255),
"Stock" INT
);Para insertar algunos registros de datos en esta tabla, pida a Joule lo siguiente:
1Show the SQL to insert the table HC200_DEMO the values 1, Bike, 15Joule respondió con el siguiente código:
123
INSERT INTO "HC200_DEMO"
VALUES (1, 'Bike', 15);Inserté registros adicionales en la tabla HC200_DEMO y ahora la tabla tenía el siguiente aspecto:
Tabla: HC200_DEMO
| ProductNumber | ProductName | Bolsa |
|---|---|---|
| 1 | "Bicicleta" | 15 |
| 2 | 'Coche' | 1 |
| 3 | "Bus" | 12 |
| 4 | "Avión" | 1 |
Selección de datos de una tabla
Desea saber qué productos tienen un inventario inferior a 5 artículos, pregunte a Joule lo siguiente:
12Show the SQL to select the field ProductName and Stock from the
table HC200_DEMO where the Stock is below 5 itemsJoule respondió con el siguiente código:
123456
SELECT
"ProductName",
"Stock"
FROM "HC200_DEMO"
WHERE "Stock" < 5;Desea saber qué productos tienen un nombre de producto que empieza por "P", pregunte a Joule lo siguiente:
12Show the SQL to select the field ProductName and Stock from the
table HC200_DEMO where the product name starts with a PJoule respondió con el siguiente código:
123456
SELECT
"ProductName",
"Stock"
FROM "HC200_DEMO"
WHERE "ProductName" LIKE 'P%';Resumen
Esta lección muestra cómo Joule puede ayudar a los administradores de bases de datos a escribir rápidamente consultas SQL comprendiendo las peticiones de lenguaje natural. El uso de Joule mejorará la productividad y reducirá los errores.