数据库实现 DDL 和 DML 的方式有区别吗?
DDL 和 DML 是用于与数据库交互的语句类型的两个严格类别。我不确定为什么存在这种分类。
Oracle 数据库在 DDL 和 DML 语句方面的内部工作方式是否存在根本区别?
DDLs and DMLs are two strict categories of types of statements used for interacting with a database. I am not sure why this categorization exists.
Is there a fundamental difference in the way an Oracle database would work internally with respect to a DDL and DML statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Oracle 中的 DDL 和 DML 之间的一个主要(技术)区别是,DDL 不是事务性的,即它们不能回滚并且不需要提交。事实上,Oracle 中的 DDL 在执行之前会进行隐式提交。
其他数据库(例如Postgres、DB2)对于DDL 和DML 之间的事务没有区别。
毕竟这只是一个分类,类似于术语“应用程序”和“服务器”(如数据库服务器中)。从操作的角度来看,OpenOffice和Oracle都只是“应用程序”,但我们将它们分为不同的类别。
One major (technical) difference between DDL and DML in Oracle is, that DDL is not transactional, i.e. they cannot be rolled back and don't require a commit. As a matter of fact DDL in Oracle does an implicit commit before it's executed.
Other databases (e.g. Postgres, DB2) do not make a difference with regards to transactions between DDL and DML
After all it's just a categorization, similar to the terms "application" and "server" (as in database server). From an operating point of view, OpenOffice and Oracle are both simply "applications", but yet we classify them into different categories.
DDL 语句用于定义数据库结构、对象和模式,而 DML 语句用于管理模式对象内的数据。最终,Oracle(或任何其他数据管理系统)将根据安全权限和对象可用性(即表/视图上的锁和隔离级别)处理每个类型语句。
此外,模式定义保存在内部主表中,因此您的 DDL 语句实际上会影响这些表中存储的数据,从这个意义上来说,也许可以将其视为“主 DML”语句。
DDL statements are used to define database structures, objects, and schemas whereas DML statements are used for managing data within schema objects. At the end of the day, Oracle (o r any other data management system) would process each type statement according to security permissions and object availability (i.e. locks on tables / views and isolation levels).
Also, schema definitions are held in internal master tables so your DDL statements actually affect the data stored in those tables and perhaps can be considered "master DML" statements in that sense.
如果您的问题是“是否有理由要求 DDL 和 DML “以不同的方式实现”,那么答案是“否”。
但是,SQL 语言的定义者选择了因此,向表中添加列必须通过适当的 ALTER TABLE 命令来完成,该命令的副作用是在记录所有列的目录表中插入一行。 >副作用
但是,没有根本原因说明为什么在目录表中插入一行不能触发列添加,因此完全不需要任何操作“专用 DDL”。
If your question amounts to "is there a reason why it is necessary for DDL and DML to "be implemented differently", the answer is "NO".
However, the definers of the SQL language have opted for making DDL syntactically distinct. As a consequence, adding a column to a table must be done through the appropriate ALTER TABLE command. A side-effect of that command is that a row gets inserted in the catalog table that documents all columns. Stress side-effect.
But there is no fundamental reason why the insertion of a row in the catalog table could not be the trigger itself for the column addition, thus entirely eliminating the need for any "dedicated DDL".