Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

搭个网页应用,让ChatGPT帮我写SQL #70

Open
CatsAndMice opened this issue Dec 3, 2023 · 0 comments
Open

搭个网页应用,让ChatGPT帮我写SQL #70

CatsAndMice opened this issue Dec 3, 2023 · 0 comments

Comments

@CatsAndMice
Copy link
Owner

大家好,我是凌览。

开门见山,我搭了一个网页应用名字叫sql-translate。访问链接挂在我的个人博客(https://linglan01.cn/about)导航栏,也可以访问https://www.linglan01.cn/c/sql-translate/直达sql-translate。

它的主要功能有:人类语言转SQL、SQL转人类语言。文章演示一下人类语言转SQL。
show time!!!

人类语言转SQL

案例一

输入:
创建了一个名为"T_USERS"的表,包含了以下字段:

  1. id:作为主键的整数类型字段。
  2. username:最大长度为50的字符串类型字段,用于存储用户名。
  3. email:最大长度为100的字符串类型字段,用于存储电子邮件地址。
  4. age:整数类型字段,用于存储年龄。
  5. gender:最大长度为10的字符串类型字段,用于存储性别信息。

ChatGPT输出:create TABLE T_USERS (id integer primary key, username varchar(50),email varchar(100),age integer gender varchar(10));

效果如此动图:

案例二

我设置Table Schema:

1CREATE TABLE T_USERS (
  id INT PRIMARY KEY,
  username VARCHAR(50),
  email VARCHAR(100),
  age INT,
  gender VARCHAR(10)
);

输入:在表名叫T_USERS 表上拓展添加学校、学历、就职公司字段
ChatGPT输出:alteb table t_users add column school varchar(100), add column education varchar(100) add column company varchar(100);

效果如此动图:

案例三

输入:查询username为程序员凌览并且email为lanling@qq.com的所有数据

ChatGPT输出:select * from t_users where username = '程序员凌览' and email = 'lanling@qq.com';

效果如此动图:

最后

无论你是初学者还是有经验的SQL用户,都可以来玩玩。我强烈推荐你尝试一下 sql-translate,少写点curd,早点下班不香吗?

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

No branches or pull requests

1 participant