ddl

Set ANSI_PADDING on a specific column (ANSI_PADDING ON and OFF in different columns of the same table)

孤街醉人 提交于 2019-12-11 01:45:35
问题 Is it possible - using a single CREATE TABLE script - to set specific varbinary columns ANSI_PADDING = ON but others to ANSI_PADDING = OFF ? e.g. CREATE TABLE PaddingX ( ... ColumnA varbinary(max), ... ColumnB varbinary(50) ) I would like ColumnA to trim (padding OFF ), but ColumnB to contain the full (padded) value - padding ON . 回答1: You hace to do it in two steps: SET ANSI_PADDING OFF -- create the table without the columns that need ANSI padding SET ANSI_PADDING ON -- alter the table to

Which Oracle view contains all constraints together?

*爱你&永不变心* 提交于 2019-12-11 01:14:38
问题 I'm trying to get CONSTRAINTS from user_objects table like this: select CASE object_type WHEN 'DATABASE LINK' then 'dblinks' WHEN 'FUNCTION' then 'functions' WHEN 'INDEX' then 'indexes' WHEN 'PACKAGE' then 'packages' WHEN 'PROCEDURE' then 'procedures' WHEN 'SEQUENCE' then 'sequences' WHEN 'TABLE' then 'tables' WHEN 'TRIGGER' then 'triggers' WHEN 'VIEW' then 'views' WHEN 'SYNONYM' then 'synonyms' WHEN 'GRANT' then 'grants' WHEN 'CONSTRAINT' then 'constraints' ELSE object_type END||'|'|| CASE

How to execute sql script after db schema generation but before application startup

匆匆过客 提交于 2019-12-10 23:35:14
问题 I want to generate DB structure from my Java classes jpa.generate-ddl: true jpa.ddl-auto: true Also, I need to run SQL script before application will up because I have @PostConstruct methods where I use these data. Can you show an example how to do it in Spring Boot? 回答1: A simple spring boot app with the required functionality can be found at. https://github.com/salilotr89/Spring-boot-postgres-dbinit Spring JDBC has a DataSource initializer feature. Spring Boot enables it by default and

Behaviour of update statistics in case when is transaction rollback

隐身守侯 提交于 2019-12-10 23:31:50
问题 In our application we are running query 'update statistics with sample 30 percent'. Our system design is such that we have to use update statistics query once a day to improve query performance. We are setting autocommit as false, running 'update statistics' and then some queries which are failing causing a connection rollback. In this case does 'update statistics' query rollback as well? Should I again run update statistics command the second time? Does 'update statistics' auto commit, or

Oracle Script problem - create trigger not terminating

蹲街弑〆低调 提交于 2019-12-10 20:21:09
问题 I am trying to make some changes to an oracle database and have a script put together to do so. The problem is when it gets to a point in the script where I am creating a trigger it seems like the Create Trigger block does not properly terminate, when I look at the trigger afterwards it contains all of the remaining code in the script. This is what I have: CREATE OR REPLACE TRIGGER user_publish_log_trg BEFORE INSERT ON USER_PUBLISH_LOG FOR EACH ROW BEGIN SELECT user_publish_log_seq.NEXTVAL

Create Table with n Columns automatically

巧了我就是萌 提交于 2019-12-10 19:01:06
问题 I want to store 236 int values to sql in one row. Now i have to declare the table but i dont want to type in 236 times the columnname. The Columnnames should be BYTE001, BYTE002, ... or something other prefix as BYTE (B, INT, ...). It is possible to generate the ColumnNames automatically? I try the following code but it does not work: USE dbXXX DECLARE @Columname varchar(10) SET @Columname = 'BYTE011' ALTER table tbl_Archiv_BYTEsps ADD @Columname int; i want to generate the columnname in a

Why doesn't a trailing comma after the last field matter when creating a table using T-SQL?

ε祈祈猫儿з 提交于 2019-12-10 17:24:31
问题 Shouldn't one of these statements work and one fail? Intuition says Statement 2 should fail because there is a comma after int and no second column listed. Yet both work and the trailing comma "," after the last column data type makes no difference. -- Statement 1 CREATE TABLE dbo.MyTable1( col1 int); -- Statement 2 CREATE TABLE dbo.MyTable2( col1 int,); However (and this is expected): two commas ",," after the last field do cause a failure: -- Statement 3 CREATE TABLE dbo.MyTable3( col1 int,

PostgreSQL indexes creation time

故事扮演 提交于 2019-12-10 17:14:41
问题 what is the query that i can use to find out when(date) a particular index (unique or non-unique) has been created in the database. Basically i want to find out the indexes that were created in the last one month or so. 回答1: This is not possible. There is no info about creating time of relations, indexes, ... 来源: https://stackoverflow.com/questions/12710588/postgresql-indexes-creation-time

`UPDATE` and `LIMIT` in `MySQL`

喜欢而已 提交于 2019-12-10 16:26:43
问题 I would like to update a specific range of rows, say starting from 30 and ending at 50 . How may I achieve that. I have tried with: UPDATE tab SET col = 'somevalue' LIMIT 30, 50 but this doesn't work. Is there any way that I can update these rows? The error that I get is: Check the manual ... for the right syntax to use near ' 50' 回答1: Your statement is not valid MySQL syntax and it doesn't make sense. The problem with the syntax is that offset is not supported for update statements (see here

Creating foreign key on same table SQLite

会有一股神秘感。 提交于 2019-12-10 14:50:05
问题 Recently I started using SQLite (as required for my study) and I came accross a couple of restrictions of SQLite and I was wondering: can't SQLite create foreign keys on the same table? E.g. this is my code: CREATE TABLE Categories ( name varchar(20), parent_category varchar(20) NULL, PRIMARY KEY(name), FOREIGN KEY parent_category_fk(parent_category) REFERENCES Categories(name) ) But it gives me an error for the foreign key when I try to execute the SQL in SQLiteStudio. Does anyone know why