创建表的SQL预准备语句 [英] SQL Prepared Statement to Create Table

查看:107
本文介绍了创建表的SQL预准备语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道一些基于用户输入(SQL Prepared Statement)动态创建表的方法

I wanted to know of some way to create table on the fly based on user input(SQL Prepared Statement)

CREATE TABLE ? (
  First_Name char(50),
  Last_Name char(50)
)

我应该用什么代替问号

推荐答案

PreparedStatement占位符不适用于表名或列名,它们仅适用于实际列值.

PreparedStatement placeholders are not intended for table names nor column names, they are only intended for actual column values.

因此,您将必须动态创建(准备好的)语句字符串,这意味着您的应用程序将容易受到SQL注入的攻击.取决于应该如何使用该应用程序-以及由谁使用-这可能是一个大问题.

So you would have to create the (prepared) statement string dynamically, which means your application will be vulnerable to SQL injection. Depending on how the application is supposed to be used - and by who - this could be a BIG problem.

这篇关于创建表的SQL预准备语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆