ddl

How do I get column datatype in Oracle with PL-SQL with low privileges?

霸气de小男生 提交于 2019-11-27 17:57:25
I have "read only" access to a few tables in an Oracle database. I need to get schema information on some of the columns. I'd like to use something analogous to MS SQL's sp_help . I see the table I'm interested in listed in this query: SELECT * FROM ALL_TABLES When I run this query, Oracle tells me "table not found in schema", and yes the parameters are correct. SELECT DBMS_METADATA.GET_DDL('TABLE', 'ITEM_COMMIT_AGG', 'INTAMPS') AS DDL FROM DUAL; After using my Oracle universal translator 9000 I've surmised this doesn't work because I don't have sufficient privileges. Given my constraints how

Superkey vs. Candidate key

淺唱寂寞╮ 提交于 2019-11-27 17:55:15
问题 What difference between Super and Candidate key in ERDB? Thanks. 回答1: A superkey is a set of columns that uniquely identifies a row. A Candidate key would be a MINIMAL set of columns that uniquely identifies a row. So essentially a Superkey is a Candidate key with extra unnecessary columns in it. 回答2: candidate key is a minimal superkey 回答3: Candidate key = minimal key to identify a row Super key = at least as wide as a candidate key For me, a super key would generally introduce ambiguities

Define default column value with annotations in Hibernate

£可爱£侵袭症+ 提交于 2019-11-27 16:19:39
问题 I know there are plenty of these questions here on SO and also on the net, but all the answers suggest using columnDefinition which is database specific and hence not applicable for me because the system I'm working on needs to run on different databases. I found this hibernate issue where someone requested this feature for annotations. The issue has been closed saying that another issue will cover that functionality. The second issue apparently added annotation @Generated and also some

Renaming a column in MS SQL Server 2005

旧城冷巷雨未停 提交于 2019-11-27 15:41:06
问题 What is the best practice when it comes to renaming a table column using SQL (MS SQL Server 2005 variant)? This assumes that there is data in the column that must be preserved. 回答1: You have to use a stored proc to rename a column. The following will rename your column from 'oldColumnName' to 'newColumnName' without affecting any data. EXEC sp_rename 'tableName.[oldColumnName]', 'newColumnName', 'COLUMN' Obviously you'll have to update any code / stored procs / SQL that uses the old name

Anyway to create a SQL Server DDL trigger for “SELECT” statements?

做~自己de王妃 提交于 2019-11-27 15:10:57
I am dealing with some sensitive Accounting tables and I would like to audit any SELECT statement executed on the table or any views associated with them. I did not find any DDL Events on BOL (Books Online) that had anything to do with SELECT statement. And DML triggers are for INSERT , UPDATE and DELETE only. Is it possible to log who accesses table and views through SELECT statement? You have 3 options: allow access via stored procedures if you want to log (and remove table rights) hide the table behind a view if you want to restrict and keep "direct" access run a permanent trace I'd go for

How do I conditionally create a table in Sybase (TSQL)?

只愿长相守 提交于 2019-11-27 13:55:49
问题 OK, so Sybase (12.5.4) will let me do the following to DROP a table if it already exists: IF EXISTS ( SELECT 1 FROM sysobjects WHERE name = 'a_table' AND type = 'U' ) DROP TABLE a_table GO But if I try to do the same with table creation, I always get warned that the table already exists, because it went ahead and tried to create my table and ignored the conditional statement. Just try running the following statement twice, you'll see what I mean: IF NOT EXISTS ( SELECT 1 FROM sysobjects WHERE

DDL(数据定义语言)

馋奶兔 提交于 2019-11-27 11:22:00
#DDL /* 数据定义语言 库和表的管理 一、库的管理 创建、修改、删除 二、表的管理 创建、修改、删除 创建: create 修改: alter 删除: drop */ #一、库的管理 #1、库的创建 /* 语法: create database [if not exists]库名; */ #案例:创建库Books CREATE DATABASE IF NOT EXISTS books ; #2、库的修改 RENAME DATABASE books TO 新库名; #更改库的字符集 ALTER DATABASE books CHARACTER SET gbk; #3、库的删除 DROP DATABASE IF EXISTS books; #二、表的管理 #1.表的创建 ★ /* 语法: create table 表名( 列名 列的类型【(长度) 约束】, 列名 列的类型【(长度) 约束】, 列名 列的类型【(长度) 约束】, ... 列名 列的类型【(长度) 约束】 ) */ #案例:创建表Book CREATE TABLE book( id INT,#编号 bName VARCHAR(20),#图书名 price DOUBLE,#价格 authorId INT,#作者编号 publishDate DATETIME#出版日期 ); DESC book; #案例

Reverse engineer DDL from JPA entities

久未见 提交于 2019-11-27 10:55:38
问题 I'm playing around with some JPA stuff, changing the mappings to see how they're supposed to be etc. It's basic experimentation. However I can't find a tool that will simply read my entities and then generate the table schema for me. I tried to find something like this in JBoss tools but nada. Eclipse integration will be a huge plus but i'll take a command line tool or an ant task. Any ideas? 回答1: I don't think there is an universal way of doing this with JPA, you have to directly use the

There can be only one auto column

我的未来我决定 提交于 2019-11-27 10:12:30
问题 How do I correct the error from MySQL 'you can only have one auto increment column'. CREATE TABLE book ( id INT AUTO_INCREMENT NOT NULL, accepted_terms BIT(1) NOT NULL, accepted_privacy BIT(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 回答1: My MySQL says "Incorrect table definition; there can be only one auto column and it must be defined as a key " So when I added primary key as below it started working: CREATE TABLE book ( id INT AUTO_INCREMENT NOT NULL, accepted_terms BIT(1) NOT NULL

SQL Column definition : default value and not null redundant?

两盒软妹~` 提交于 2019-11-27 09:49:12
问题 I've seen many times the following syntax which defines a column in a create/alter DDL statement: ALTER TABLE tbl ADD COLUMN col VARCHAR(20) NOT NULL DEFAULT "MyDefault" The question is: since a default value is specified, is it necessary to also specify that the column should not accept NULLs ? In other words, doesn't DEFAULT render NOT NULL redundant ? 回答1: DEFAULT is the value that will be inserted in the absence of an explicit value in an insert / update statement. Lets assume, your DDL