ddl

How can I generate (or get) a ddl script on an existing table in oracle? I have to re-create them in Hive

我是研究僧i 提交于 2019-11-26 23:22:03
问题 How can I generate a DDL script on an existing table in oracle? I am working on a project where I have to re-create some tables that are present in Oracle table into Hive. 回答1: If your SQL client doesn't support this, then you can use the dbms_metadata package to get the source for nearly everything in your database: For a table use something like this: select dbms_metadata.get_ddl('TABLE', 'YOUR_TABLE_NAME') from dual; You can also do this for all tables at once: select dbms_metadata.get_ddl

Is it possible to run multiple DDL statements inside a transaction (within SQL Server)?

空扰寡人 提交于 2019-11-26 23:03:01
I'm wondering if it is possible to run multiple DDL statements inside a transaction. I'm specially interested on SQL Server, even though answers with other databases (Oracle, PostgreSQL at least) could also be interesting. I've been doing some "CREATE TABLE" and "CREATE VIEW" for the created table inside a transaction and there seems to be some inconsistencies and I'm wondering if the DDLs shouldn't be done inside the transaction... I could probably move the DDL outside the transaction but I'd like to get some reference for this. What I have found this far: MSDN page Isolation Levels in the

How to get function parameter lists (so I can drop a function)

大憨熊 提交于 2019-11-26 22:40:50
I want to get the SQL to drop a function in PostgreSQL. I write DROP FUNCTION and a get function name from pg_proc . That is not problem. However if I leave blank parameters it will not drop the function. I checked the manual and there is written then I have to identify the function with its parameters to drop it, eg DROP FUNCTION some_func(text,integer) not just DROP FUNCTION some_func . Where can I find the parameters? In the function's row on in the pg_proc table there is no parameters. So how can I get the SQL to drop the function? Postgres has a dedicated function for that purpose.

Create user from string variables in a PL/SQL block

不羁岁月 提交于 2019-11-26 22:08:10
问题 I use Oracle XE for the sole purpose of developing PHP applications and version 11g has apparently lost the GUI tool to manage users which 10g used to have so I'd like to prepare a code snippet to create users from command line. I'm trying to define variables so I don't need to type the same user name 16 times but I can't get the syntax right: DECLARE my_user VARCHAR2(30) := 'foo'; my_password VARCHAR2(9) := '1234'; BEGIN CREATE USER my_user IDENTIFIED BY my_password DEFAULT TABLESPACE users;

how does exactly spring.jpa.hibernate.ddl-auto property works in Spring?

旧城冷巷雨未停 提交于 2019-11-26 22:07:36
I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some script migration with FlyWay but it works after several tries. Then I noticed that I didn't specify spring.jpa.hibernate.ddl-auto in my properties file. I did some research and found that it is recommended to add spring.jpa.hibernate.ddl-auto= create-drop in development. And change it to: spring.jpa.hibernate.ddl-auto= none in production. But I didn't actually understood how does it really work

Invalid column name on sql server update after column create

耗尽温柔 提交于 2019-11-26 21:28:54
问题 Does anyone see what's wrong with this code for SQL Server? IF NOT EXISTS(SELECT * FROM sys.columns WHERE Name = 'OPT_LOCK' AND object_ID = Object_id('REP_DSGN_SEC_GRP_LNK')) BEGIN ALTER TABLE REP_DSGN_SEC_GRP_LNK ADD OPT_LOCK NUMERIC(10, 0) UPDATE REP_DSGN_SEC_GRP_LNK SET OPT_LOCK = 0 ALTER TABLE REP_DSGN_SEC_GRP_LNK ALTER COLUMN OPT_LOCK NUMERIC(10, 0) NOT NULL END; When I run this, I get: Msg 207, Level 16, State 1, Line 3 Invalid column name 'OPT_LOCK'. on the update command. Thanks. 回答1:

Generate DDL programmatically on Postgresql

旧巷老猫 提交于 2019-11-26 20:32:27
问题 How can I generate the DDL of a table programmatically on Postgresql? Is there a system query or command to do it? Googling the issue returned no pointers. 回答1: Use pg_dump with this options: pg_dump -U user_name -h host database -s -t table_or_view_names -f table_or_view_names.sql Description: -s or --schema-only : Dump only ddl / the object definitions (schema), without data. -t or --table Dump : Dump only tables (or views or sequences) matching table Examples: -- dump each ddl table that

DML、DDL、DCL区别

社会主义新天地 提交于 2019-11-26 19:57:16
总体解释: DML(data manipulation language): 它们是SELECT、UPDATE、INSERT、DELETE,就象它的名字一样,这4条命令是用来对 数据库 里的数据进行操作的语言 DDL(data definition language): DDL比DML要多,主要的命令有CREATE、ALTER、DROP等,DDL主要是用在定义或改变表(TABLE)的结构,数据类型,表之间的链接和约束等初始化工作上,他们大多在建立表时使用 DCL(Data Control Language): 是数据库控制功能。是用来设置或更改数据库用户或角色权限的语句,包括(grant,deny,revoke等)语句。在默认状态下,只有sysadmin,dbcreator,db_owner或db_securityadmin等人员才有权力执行DCL 详细解释: 一、DDL is Data Definition Language statements. Some examples:数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 1.CREATE - to create objects in the database 创建 2.ALTER - alters the structure of the database 修改 3.DROP - delete objects

DDL、DML和DCL 区别与理解

丶灬走出姿态 提交于 2019-11-26 19:56:59
这篇文章主要介绍了DDL、DML和DCL的区别与理解,需要的朋友可以参考下 DML、DDL、DCL区别 . 总体解释: DML(data manipulation language): 它们是SELECT、UPDATE、INSERT、DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据进行操作的语言 DDL(data definition language): DDL比DML要多,主要的命令有CREATE、ALTER、DROP等,DDL主要是用在定义或改变表(TABLE)的结构,数据类型,表之间的链接和约束等初始化工作上,他们大多在建立表时使用 DCL(Data Control Language): 是数据库控制功能。是用来设置或更改数据库用户或角色权限的语句,包括(grant,deny,revoke等)语句。在默认状态下,只有sysadmin,dbcreator,db_owner或db_securityadmin等人员才有权力执行DCL 详细解释: 一、DDL is Data Definition Language statements. Some examples:数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 1.CREATE - to create objects in the database 创建 2.ALTER - alters the

Oracle --DML、DDL、DCL

不问归期 提交于 2019-11-26 19:56:45
DML、DDL、DCL的区别 1. DML概述:(data manipulation language),数据操纵语言。用于操纵数据库对象中包含的数据,也就是说操纵的对象是记录。 1.1 DML的主要语句(即操作语句) insert语句:向表中插入一条记录。 delete语句:删除数据表中一条或多条记录。 update语句:用于修改表中的记录。 备注:由上可以看出DML操作的对象是表中的记录。 2. DDL概述:(data definition language),数据定义语言。用于操作对象(eg:数据库表)和对象的属性(eg:表字段),这种对象包括数据库本身以及数据库对象,例如:表、视图等。DDL主要的命令有:create、alter、drop等,ddl主要用来定义或改变表(table)结构,改变数据类型,改变表之间的连接和约束等初始化工作上,这些工作大多数在建立表时使用。 2.1 DDL的主要语句 create语句:创建数据库表。 alter语句:更改表定义及表的字段。 drop语句:删除表 备注:由上可以看出,DDL操作的对象是数据库表。 3. DCL概述:(data control language),数据控制语言。用来设置或更改数据库用户或更改数据库角色权限等。 3.1 DCL的主要语句 grant语句:授权语句,它可以将语句权限或者对象权限授给其他用户或角色。