ddl

Simulate CREATE DATABASE IF NOT EXISTS for PostgreSQL?

夙愿已清 提交于 2019-12-27 13:34:06
问题 I want to create a database which does not exist through JDBC. Unlike MySQL, PostgreSQL does not support create if not exists syntax. What is the best way to accomplish this? The application does not know if the database exists or not. It should check and if the database exists it should be used. So it makes sense to connect to the desired database and if connection fails due to non-existence of database it should create new database (by connecting to the default postgres database). I checked

Delete column from SQLite table

对着背影说爱祢 提交于 2019-12-27 10:43:10
问题 I have a problem: I need to delete a column from my SQLite database. I wrote this query alter table table_name drop column column_name but it does not work. Please help me. 回答1: From: http://www.sqlite.org/faq.html: (11) How do I add or delete columns from an existing table in SQLite. SQLite has limited ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to make more complex changes in the structure of a table, you will have

SQL DML 和 DDL

北城以北 提交于 2019-12-26 23:45:05
可以把 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 - 删除索引 来源: https://www.cnblogs.com/dongboke/p/10603383.html

-sql -DDL

流过昼夜 提交于 2019-12-25 23:53:08
列操作 123456789101112 desc 表名; ...................................... #查看表结构alter table 表名 add 列名称 属性; .............. # 添加列alter table 表名 add 列名称 属性 after 列名; ... # 指定在某列后面添加alter table 表名 drop 列名; .............. #删除列名alter table 表名 change 旧列名 新列名 新属性 ..... #修改列名alter table a modify change_username varchar(20) ; # 修改列属性alter table a add new_username char(10); # 添加列alter table a add new_username2 char(10) after id; # 添加列,指定在某列后面添加alter table a drop new_username2; #删除列名alter table a change new_username change_username char(5); # 修改列名alter table a modify change_username varchar(20); #修改列属性 表操作

i am migrtaing database from sql server 2008 to teradata

我的未来我决定 提交于 2019-12-25 13:53:11
问题 I am migrating a database from Sql Server 2008 to Teradata and I am facing a problem: In Sql Server in the ddl of a table column is defined as follows: [rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Address_rowguid] DEFAULT (NEWID()) This column uses newid() function to generate and insert random varchar value in the column [rowguid] if the user doesnt provide any input. There is no similar function in Teradata to generate this value. What can be used instead of of NEWID()

MySQL FOREIGN KEY error, ON DELETE CASCADE

烈酒焚心 提交于 2019-12-25 04:31:32
问题 I have absolutely no clue why MySQL is having an issue with the second CREATE TABLE statement. CREATE TABLE User( uid INTEGER, url CHAR(100), firstname CHAR(40), lastname CHAR(40), PRIMARY KEY(uid) ); The below is the one that causes problems: CREATE TABLE Follows( uid INTEGER, url CHAR(100), PRIMARY KEY(uid,url), FOREIGN KEY(uid) REFERENCES User(uid), ON DELETE CASCADE, FOREIGN KEY(url) REFERENCES User(url), ON DELETE CASCADE ); Error I get is: #1064 - You have an error in your SQL syntax;

Trigger at Database Level on DDL Statments

﹥>﹥吖頭↗ 提交于 2019-12-25 04:31:01
问题 How to create a database level trigger on DDL statements in Microsoft SQL ? 回答1: A nice example here USE YourDatabase; GO CREATE TABLE ddl_log (PostTime datetime, DB_User nvarchar(100), Event nvarchar(100), TSQL nvarchar(2000)); GO CREATE TRIGGER log ON DATABASE FOR DDL_DATABASE_LEVEL_EVENTS AS DECLARE @data XML SET @data = EVENTDATA() INSERT ddl_log (PostTime, DB_User, Event, TSQL) VALUES (GETDATE(), CONVERT(nvarchar(100), CURRENT_USER), @data.value('(/EVENT_INSTANCE/EventType)[1]',

How to solve this error “Could not load file or assembely 'System.Dynamic' or one of its dependencies”

邮差的信 提交于 2019-12-25 01:28:51
问题 I am working on a .Net project 3.5 frame work (Sharepoint server) My project is working fine but when I deployed the wsp of the following solution in another machine having same configuration and 3.5 .NET Framework and all similar setting to that of my machine I am getting this error: Could not load file or assembly 'System.Dynamic' or one of its dependencies I have added all the DLLs which is in my project. whereas the same code /project is running well and good in my machine. How can I add

Enhance generated DDL of EclipseLink

痞子三分冷 提交于 2019-12-24 13:33:48
问题 Is it possible to change the generated DDL statements of EclipseLink during the creation process? In the persistence.xml I use the table-creation-suffix, but it adds only some things to the CREATE TABLE statements. There are also a lot of ALTER TABLE statements, which I can not change. Something like a table-alteration-suffix would be nice. <property name="eclipselink.ddl-generation.table-creation-suffix" value=";" /> <property name="eclipselink.ddl-generation" value="drop-and-create-tables"

SymmetricDS replication DDL statements

懵懂的女人 提交于 2019-12-24 09:48:09
问题 Now I try to replicate DDL statements(like create, alter, drop) between different databases with the help of Symmetric-DS. I've found this page https://www.symmetricds.org/docs/how-to/sync-schema-ddl-changes and found that it could be done it that way: bin/symadmin -e root-000 --node=001 sync-triggers bin/symadmin -e root-000 --node=001 send-schema But, for now I cannot understand that is there possibility to replicate DDL statements automatically? I.e. I create table on one database and it