ddl

Removing COMMENT ON from all objects in PostgreSQL

大兔子大兔子 提交于 2021-02-20 16:19:11
问题 In the same vein as pg_dump without comments on objects?, is anyone aware of a command to quickly get rid of the comments (created with COMMENT ON ) on all objects at once ? For now, I resorted to bash generating a SQL script that would void one by one the comments on each table/view/column, but it is quite slow, especially with >4000 columns. Example: COMMENT ON COLUMN table1.column1 IS NULL; COMMENT ON COLUMN table1.column2 IS NULL; COMMENT ON COLUMN table1.column3 IS NULL; ... 回答1: I have

Add auto increment column to existing table ordered by date

狂风中的少年 提交于 2021-02-18 11:57:08
问题 I have an existing table named "tickets" in database with columns: id (string, Primary Key, contains UUID like e6c49164-545a-43a1-845f-73c5163962f2) date (biginteger, stores epoch) status (string) I need to add new auto increment column ticket_id but the values to be generated should be according to "date" column value. I tried this: ALTER TABLE "tickets" ADD COLUMN "ticket_id" SERIAL; The problem is, it is generating "ticket_id" values in some weird order, looks like it is based on "id"

Add auto increment column to existing table ordered by date

给你一囗甜甜゛ 提交于 2021-02-18 11:57:07
问题 I have an existing table named "tickets" in database with columns: id (string, Primary Key, contains UUID like e6c49164-545a-43a1-845f-73c5163962f2) date (biginteger, stores epoch) status (string) I need to add new auto increment column ticket_id but the values to be generated should be according to "date" column value. I tried this: ALTER TABLE "tickets" ADD COLUMN "ticket_id" SERIAL; The problem is, it is generating "ticket_id" values in some weird order, looks like it is based on "id"

Error executing DDL "create table in Spring Data JPA?

淺唱寂寞╮ 提交于 2021-02-10 12:18:42
问题 I want to save some data coming from the request. for that, I created some entity classes. but why I et this exception? Error executing DDL "create table body_datum (body_datum_id integer not null, key varchar(255), value varchar(255), value_type varchar(255), primary key (body_datum_id)) engine=InnoDB" via Here are my properties. spring.datasource.url= jdbc:mysql://localhost:3306/loadtestdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Error executing DDL "create table in Spring Data JPA?

ぐ巨炮叔叔 提交于 2021-02-10 12:15:41
问题 I want to save some data coming from the request. for that, I created some entity classes. but why I et this exception? Error executing DDL "create table body_datum (body_datum_id integer not null, key varchar(255), value varchar(255), value_type varchar(255), primary key (body_datum_id)) engine=InnoDB" via Here are my properties. spring.datasource.url= jdbc:mysql://localhost:3306/loadtestdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Added date and modified date for Oracle table audit

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 04:39:35
问题 According to requirenments I need to support two mandatory columns for each table: ADDED_DATE, MODIFIED_DATE. These are intended for DBA/auditing purposes. Is it possible to make this stuff totally automatic, implicitly supported by DB itself when I'm inserting / updating records from within application? 回答1: create a trigger on the table (before update for each row). SQL> create table foo (hi varchar2(10), added_date date, modified_date date); Table created. SQL> create trigger foo_auifer 2

Creating a table if it doesn't exist already

牧云@^-^@ 提交于 2021-02-04 21:39:02
问题 I'm trying to create a table if it doesn't exist already. I'm currently checking to see if it exists in DBA_TABLES first and if that query returns nothing then insert. Is there a way to just check in the same statement so I don't have to break it up into separate queries? This is what I have currently. BEGIN SELECT COUNT(*) INTO lvnTableExists FROM DBA_TABLES WHERE Table_Name = 'SOME_TABLE'; IF lvnTableExists = 0 THEN EXECUTE IMMEDIATE 'CREATE TABLE SOME_TABLE AS (SELECT * FR0M OTHER_TABLE)';

Creating a table if it doesn't exist already

╄→尐↘猪︶ㄣ 提交于 2021-02-04 21:35:47
问题 I'm trying to create a table if it doesn't exist already. I'm currently checking to see if it exists in DBA_TABLES first and if that query returns nothing then insert. Is there a way to just check in the same statement so I don't have to break it up into separate queries? This is what I have currently. BEGIN SELECT COUNT(*) INTO lvnTableExists FROM DBA_TABLES WHERE Table_Name = 'SOME_TABLE'; IF lvnTableExists = 0 THEN EXECUTE IMMEDIATE 'CREATE TABLE SOME_TABLE AS (SELECT * FR0M OTHER_TABLE)';

Special characters in AWS Athena show up as question marks

我的梦境 提交于 2021-01-29 11:08:42
问题 I've added a table in AWS Athena from a csv file, which uses special characters "æøå". These show up as � in the output. The csv file is encoded using unicode. I've also tried changing the encoding to UTF-8, with no luck. I've uploaded the csv in S3 and then added the table to Athena using the following DDL: CREATE EXTERNAL TABLE `regions_dk`( `postnummer` string COMMENT 'from deserializer', `kommuner` string COMMENT 'from deserializer', `regioner` string COMMENT 'from deserializer') ROW

Aws Athena - Rename column name

纵然是瞬间 提交于 2021-01-28 04:20:37
问题 I am trying to change a column name in an AWS Athena table. From old_name to new_name . Normal DDL commands does not affect the table (They cannot be executed). Is It possible to change a column name without deleting and re-creating the table from scratch ? 回答1: I was mistaken, Athena uses HIVE DDL syntax so the correct command is : ALTER TABLE %%table-name%% CHANGE %%old-column-name%% %%new-column-name%%<string>; I based my answer on a hive related question. 回答2: You can find more about