ddl

SQL四种语言:DDL,DML,DCL,TCL

◇◆丶佛笑我妖孽 提交于 2019-12-03 05:20:59
1. DDL ( Data Definition Language ) 数据库 定义语言 statements are used to define the database structure or schema. DDL是 SQL 语言的四大功能之一。 用于定义数据库的三级结构,包括外模式、概念模式、内模式及其相互之间的映像,定义数据的完整性、安全控制等约束 DDL不需要commit. CREATE ALTER DROP TRUNCATE COMMENT RENAME 2. DML ( Data Manipulation Language ) 数据操纵语言 statements are used for managing data within schema objects. 由DBMS提供,用于让用户或程序员使用,实现对数据库中数据的操作。 DML分成交互型DML和嵌入型DML两类。 依据语言的级别,DML又可分成过程性DML和非过程性DML两种。 需要commit. SELECT INSERT UPDATE DELETE MERGE CALL EXPLAIN PLAN LOCK TABLE 3. DCL ( Data Control Language ) 数据库控制语言 授权,角色控制等 GRANT 授权 REVOKE 取消授权 4. TCL ( Transaction

How can I automatically convert MySQL DDL to Oracle DDL? [closed]

雨燕双飞 提交于 2019-12-03 03:01:39
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I know my question sounds a little bit like a shopping request, but I honestly believe that many people could find it useful. I've been looking for an automatic tool that converts Data Definition Language from MySQL dialect to Oracle dialect - the other way round would also be fine. I found “SQL Fairy” but I was unable to run it; probably because I'm not familiar with PERL. Is there any free tool for Windows that

In DB2 Display a table's definition

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one. Similar to the EXPLAIN TABLE command in MySQL. Thank you. 回答1: In addition to DESCRIBE TABLE, you can use the below DESCRIBE INDEXES FOR TABLE *tablename* SHOW DETAIL to get information about the table's indexes. The most comprehensive detail about a table on DB2 for Linux, UNIX, and Windows can be obtained from the db2look utility, which you can run from a remote client or directly on the DB2 server as a local user. The tool

How to generate DDL for all tables in a database in MySQL

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to generate the DDL for all tables in a database of MySQL at once. I know that the following query will output the DDL for a table. But I want DDL of all tables at once because I am having hundreds of tables in my database. show create table <database name>.<table name>; For example: show create table projectdb.customer_details; The above query will result in DDL of customer_details table. I am using MySQL with MySQL workbench on Windows OS. 回答1: You can do it using the mysqldump command line utility: mysqldump -d -u <username> -p

Is string or int preferred for foreign keys?

对着背影说爱祢 提交于 2019-12-03 02:40:34
I have a user table with userid and username columns, and both are unique. Between userid and username , which would be better to use as a foreign key and why? My Boss wants to use string, is that ok? It looks like you have both a surrogate key ( int userId ) and a natural key ( char or varchar username ). Either column can be used as a Primary key for the table, and either way, you will still be able to enforce uniqueness of the other key. There are many existing discussions on the trade-offs between Natural and Surrogate Keys - you will need to decide on what works for you, and what the

Do DDL statements always give you an implicit commit, or can you get an implicit rollback?

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If you're halfway through a transaction and perform a DDL statement, such as truncating a table, then the transaction commits. I was wondering whether this was always the case and by definition, or is there a setting hidden somewhere that would rollback the transaction instead of committing. Thanks. Edit to clarify... I'm not looking to rollback after a truncate. I just want to confirm that statements already carried out are absolutely always going to be committed before a DDL. Just want to make sure there isn't a system property somewhere

Why cannot I use bind variables in DDL/SCL statements in dynamic SQL?

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to execute an SQL command within dynamic SQL with bind variables: -- this procedure is a part of PL/SQL package Test_Pkg PROCEDURE Set_Nls_Calendar(calendar_ IN VARCHAR2) IS BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_CALENDAR = :cal' USING IN calendar_; END Set_Nls_Calendar; Then on the client side, I am trying to invoke the procedure: Test_Pkg.Set_Nls_Calendar('Thai Buddha'); But this get's me ORA-02248: invalid option for ALTER SESSION . And my question is: Why cannot I use bind variables in DDL/SCL statements in dynamic

SQL的DDL和DML

我的未来我决定 提交于 2019-12-03 01:24:54
DDL:数据定义语言,定义库、表结构用的 DML:数据操作语言,增、删、改、查 DCL:数据控制语言,权限、事务等控制语句 (一)DDL 1、操作数据库的语句 (1)查看当前DBMS中的所有数据库 show databases; (2)创建一个数据库 create database 数据库名; (3)删除一个数据库 drop database 数据库名; (4)使用,指定使用哪个数据库 use 数据库名; 有了这句后,下面的sql都是默认针对这个数据库的操作。 2、操作表格的语句 (1)查看某个库的所有表格 show tables; #必须前面有use 数据库名;的语句 否则报no database select的错误 show tables from 数据库名; (2)创建表格 基本版: create table 【数据库名.】表名称( 字段名1 数据类型, 字段名2 数据类型, 字段名2 数据类型, .... ); create table 【数据库名.】表名称(字段名1 数据类型,字段名2 数据类型,字段名2 数据类型,....); 注意:最后一个字段名的数据类型后面就不用加, 例如: create table employee( id int, name varchar(20), age int, salary double, gender char, birthday

Oracle: DBMS_UTILITY.EXEC_DDL_STATEMENT vs EXECUTE IMMEDIATE

社会主义新天地 提交于 2019-12-03 01:24:03
Which are the differences between DBMS_UTILITY.EXEC_DDL_STATEMENT and EXECUTE IMMEDIATE ? Fundamentally they do the same thing, which is to provide a mechanism to execute DDL statements in PL/SQL, which isn't supported natively. If memory serves me well, the EXEC_DDL_STATEMENT was available in the Oracle 7 version of the DBMS_UTILITY package, whereas Native Dynamic SQL (EXECUTE IMMEDIATE) was only introduced in 8. There are a couple of differences. EXECUTE IMMEDIATE is mainly about executing dynamic SQL (as its NDS name indicates). the fact that we can use it for DDL is by-the-by. But the DBMS

Oracle How to grant CREATE ANY DIRECTORY with the restriction that all directories must be created inside a given directory?

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to grant the CREATE ANY DIRECTORY permission to a user, with the following restriction: all directories created by this user must be inside of /foo/bar , and any attempt to create a directory outside of this should fail with a permission error. How may I do this on Oracle 11G or 12C? 回答1: That depends, if you want to restrict which OS directories Oracle can access from utl_file commands, you can set the utl_file_dir parameter. Unfortunately, this parameter is system wide, so you won't be able to grant/revoke for a specific user using