ddl

Drop or create database from stored procedure in PostgreSQL

早过忘川 提交于 2019-12-20 02:16:11
问题 I have a function that looks like this: BEGIN DROP DATABASE IF EXISTS db_1; END; I'm getting the following error: ERROR: DROP DATABASE cannot be executed from a function or multi-command string. Is it not possible to drop a database from a stored procedure in PostgreSQL? I'm using plpgsql. 回答1: The error message is just a s clear as the manual on this: DROP DATABASE cannot be executed inside a transaction block. A plgpsql function is surrounded by a transaction block automatically. The long

How best can I recreate an Oracle database?

筅森魡賤 提交于 2019-12-20 01:46:12
问题 Oracle 11gR2 (x86 Windows): I have a db with 250 tables with indexes and constraints. I need to re-create these tables, indexes and constraints in a new db and load the data. I need to know how to do the following in SQL Plus and/or SQL Developer, unless there's a magical utility that can automate all of this. Thanks in advance! Unload (export) all the data from the 250 tables. Create an sql script file containing the CREATE TABLE statements for the 250 tables. Create an sql script file

SQL DML和DDL

醉酒当歌 提交于 2019-12-20 00:15:09
SQL DML 和 DDL 可以把 SQL 分为两个部分:数据操作语言(DML) 和 数据定义语言 (DDL)。 SQL (结构化查询语言)是用于执行查询的语法。但是 SQL 语言也包含用于更新、插入和删除记录的语法。 查询和更新指令构成了 SQL 的 DML 部分: SELECT - 从数据库表中获取数据 UPDATE - 更新数据库表中的数据 DELETE - 从数据库表中删除数据 INSERT INTO - 向数据库表中插入数据 SQL 的数据定义语言 (DDL) 部分使我们有能力创建或删除表格。我们也可以定义索引(键),规定表之间的链接,以及施加表间的约束。 SQL 中最重要的 DDL 语句: CREATE DATABASE - 创建新数据库 ALTER DATABASE - 修改数据库 CREATE TABLE - 创建新表 ALTER TABLE - 变更(改变)数据库表 DROP TABLE - 删除表 CREATE INDEX - 创建索引(搜索键) DROP INDEX - 删除索引 来源: CSDN 作者: China.wyb 链接: https://blog.csdn.net/qq_37839971/article/details/103609789

ALTER TABLE: Add a new boolean column with default value and checkbox

守給你的承諾、 提交于 2019-12-19 19:57:39
问题 What is the correct Access DDL query to add a Boolean datatype column to a table? So far I've seen examples like the following... ALTER TABLE MyTable ADD MyNewColumName BIT but they do not seem to be 100% correct since Access does not apply the checkbox control to the newly added column, and the allowed values for that column seem to be 0 and -1 回答1: A DAO example. ''Requires reference to Microsoft DAO 3.6 Object Library Dim tdf As DAO.TableDef Dim fld As DAO.Field Dim db As Database Dim

Change timezone component of TIMESTAMP WITH TIMEZONE in Oracle

早过忘川 提交于 2019-12-19 19:54:40
问题 I have some data that is stored in a TIMESTAMP(6) WITH TIMEZONE column in Oracle, but it is stored in the wrong timezone. By convention, all timestamps in the DB must be stored in UTC, but this data was incorrectly persisted as EDT. The actual values are equivalent to the correct UTC value; the problem is simply that it is stored as 19-JUN-12 12.20.42.000000000 PM AMERICA/NEW_YORK when instead it should be 19-JUN-12 16.20.42.000000000 PM UTC . Is there any way in Oracle to change this? 回答1:

Get definition of function, sequence, type etc. in Postgresql with SQL query

吃可爱长大的小学妹 提交于 2019-12-18 13:01:36
问题 I need the create scripts for PostgreSQL database objects. I have not access to pg_dump. So I have to get everything with SQL queries. How could I do this? 回答1: To get the definition of a function use pg_get_functiondef() : select pg_get_functiondef(oid) from pg_proc where proname = 'foo'; There are similar functions to retrieve the definition of an index, a view, a rule and so on. For details see the manual: http://www.postgresql.org/docs/current/static/functions-info.html Getting the

Get definition of function, sequence, type etc. in Postgresql with SQL query

狂风中的少年 提交于 2019-12-18 13:01:28
问题 I need the create scripts for PostgreSQL database objects. I have not access to pg_dump. So I have to get everything with SQL queries. How could I do this? 回答1: To get the definition of a function use pg_get_functiondef() : select pg_get_functiondef(oid) from pg_proc where proname = 'foo'; There are similar functions to retrieve the definition of an index, a view, a rule and so on. For details see the manual: http://www.postgresql.org/docs/current/static/functions-info.html Getting the

ORA-00600 When running ALTER command?

谁说胖子不能爱 提交于 2019-12-18 07:08:44
问题 I am running this command on a table : ALTER TABLE testTable ADD column1 NUMBER(1) DEFAULT 0 NOT NULL; And i keep getting this error: Error report: SQL Error: ORA-00600: internal error code, arguments: [kkpoffoc], [], [], [], [], [], [], [], [], [], [], [] 00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]" *Cause: This is the generic internal error number for Oracle program exceptions. This indicates that a process has encountered an exceptional

Creating a trigger to only run when a new table is being created

爱⌒轻易说出口 提交于 2019-12-18 04:55:08
问题 I know that I can use this to create DDL create trigger; CREATE OR REPLACE TRIGGER create_table_trigger AFTER CREATE ON SCHEMA DECLARE BEGIN END; Problem is this trigger would run on DDLs like 'Create sequence'; how can I only execute this for 'Create Table' DDLs? 回答1: CREATE OR REPLACE TRIGGER create_table_trigger AFTER CREATE ON SCHEMA BEGIN IF SYS.DICTIONARY_OBJ_TYPE = 'TABLE' THEN .... END; For a list of EVENT attributes, refer to this page http://ist.marshall.edu/ist480adbp/plsql

Generate DDL script at MAVEN build with Hibernate4 / JPA 2.1

女生的网名这么多〃 提交于 2019-12-18 01:18:29
问题 It seems like the hibernate3-maven-plugin used to generate DDL create/drop scripts is not compatible any more with Hibernate 4.3 and newer versions (using JPA 2.1 ). I use this plugin configuration : <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>3.0</version> <executions> <execution> <id>generate-sql-schema</id> <phase>process-sources</phase> <goals> <goal>hbm2ddl</goal> </goals> <configuration> <hibernatetool> <jpaconfiguration