ddl

How to add a calculated column to Access via SQL

廉价感情. 提交于 2019-12-01 20:12:50
How do i add a calculated column to an Access table in SQL? I know i can add a column with SQL like this: ALTER TABLE Clients ADD COLUMN AccountDate TEXT(60) Thanks, Vítor You cannot add a calculated column with SQL because calculated field requires an expression and that cannot be supplied through SQL. Technically, a calculated field is a base type - int, double, text etc. Above the base type is an expression that helps Access do the math/logic. You could use VBA to create a calculated column -- create a module and let's assume that -- your table has Field1 integer and Field2 integer -- we

SQL Server 2012

こ雲淡風輕ζ 提交于 2019-12-01 19:55:22
问题 Is there a way to export DDL for SQL Server 2012? A previous question of this nature was answered in Dec 2009, but it does not seem to apply, Previous answer: For SQL Server: In SQL Server Management Studio, right click on your database and choose 'Tasks' -> 'Generate Scripts'. You will be asked to choose which DDL objects to include in your script. link edited Dec 19 '09 at 8:58 answered Dec 18 '09 at 18:53 Daniel Vassallo 78.6k11129180 I've tried the suggestion, but after right-clicking on

How to get the name of the altered table in a Postgres event trigger?

本秂侑毒 提交于 2019-12-01 19:41:37
问题 in a postgres database, have table base1 that is the base table for view view1 . if a column in base1 is created, dropped or renamed, I would like to recreate the view view1 with a ddl trigger. create event trigger base1_views on ddl_command_end when tag in( 'ALTER TABLE' ) execute procedure base1_views_fn(); create function base1_views_fn() returns void as $$ declare buf varchar; begin -- is table being altered = 'base'? -- add, drop or renaming a column? buf = 'drop view view1'; execute buf

In JDBC how does one know if the DDL statement was executed successfully?

旧巷老猫 提交于 2019-12-01 18:47:18
问题 I am trying to execute a DDL statement on a Oracle 11g database using JDBC. I am doing it using the boolean execute(String SQL) of the Statement class. Following is the code snippet that executes the query and tries to determine the result of the query: // Create a SQL string String dropSql = "DROP TABLE Reviews"; stmt = conn.createStatement(); // Execute the query boolean result = stmt.execute(dropSql); // Get the result of the drop operation if(result) { // Its a result set System.out

How to get the name of the altered table in a Postgres event trigger?

让人想犯罪 __ 提交于 2019-12-01 18:22:08
in a postgres database, have table base1 that is the base table for view view1 . if a column in base1 is created, dropped or renamed, I would like to recreate the view view1 with a ddl trigger. create event trigger base1_views on ddl_command_end when tag in( 'ALTER TABLE' ) execute procedure base1_views_fn(); create function base1_views_fn() returns void as $$ declare buf varchar; begin -- is table being altered = 'base'? -- add, drop or renaming a column? buf = 'drop view view1'; execute buf; buf = 'create view view1 as select * from base1 where ...'; execute buf; end; $$ language 'plpgsql';

In JDBC how does one know if the DDL statement was executed successfully?

我是研究僧i 提交于 2019-12-01 18:20:44
I am trying to execute a DDL statement on a Oracle 11g database using JDBC. I am doing it using the boolean execute(String SQL) of the Statement class. Following is the code snippet that executes the query and tries to determine the result of the query: // Create a SQL string String dropSql = "DROP TABLE Reviews"; stmt = conn.createStatement(); // Execute the query boolean result = stmt.execute(dropSql); // Get the result of the drop operation if(result) { // Its a result set System.out.println("Atleast one result set has been returned. Loop through them"); } else { // Its an update count or

SQL Server 2012

微笑、不失礼 提交于 2019-12-01 18:17:57
Is there a way to export DDL for SQL Server 2012? A previous question of this nature was answered in Dec 2009, but it does not seem to apply, Previous answer: For SQL Server: In SQL Server Management Studio, right click on your database and choose 'Tasks' -> 'Generate Scripts'. You will be asked to choose which DDL objects to include in your script. link edited Dec 19 '09 at 8:58 answered Dec 18 '09 at 18:53 Daniel Vassallo 78.6k11129180 I've tried the suggestion, but after right-clicking on my database, these is no such "Tasks" option. Any ideas? 2012 Analysis Services just has a deployment

Change timezone component of TIMESTAMP WITH TIMEZONE in Oracle

♀尐吖头ヾ 提交于 2019-12-01 17:59:59
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? Do you really need to change the data that is stored in the database? Normally, it's sufficient just to

Setting the comment of a column to that of another column in Postgresql

雨燕双飞 提交于 2019-12-01 17:20:40
Suppose I create a table in Postgresql with a comment on a column: create table t1 ( c1 varchar(10) ); comment on column t1.c1 is 'foo'; Some time later, I decide to add another column: alter table t1 add column c2 varchar(20); I want to look up the comment contents of the first column, and associate with the new column: select comment_text from (what?) where table_name = 't1' and column_name = 'c1' The (what?) is going to be a system table, but after having looked around in pgAdmin and searching on the web I haven't learnt its name. Ideally I'd like to be able to: comment on column t1.c1 is

数据库基本知识(一)——DDL语句

半世苍凉 提交于 2019-12-01 16:59:11
DDL:数据定义语言,对数据库内部对象进行创建、删除、修改等操作的语言。 1. 创建 数据库: CREATE DATABASE dbname 2. 查看 存在哪些数据库: SHOW DATABASES 查看存在哪些数据表: SHOW TABLES 3. 选择 要操作的数据库: USE dbname 4. 删除 数据库: DROP DATABASE dbname 删除表: DROP TABLE tablename 5.在数据库中 创建 一张表: CREATE TABLE tablename( column_1 column_type1 constraints , column_2 column_type2 constraints) 6. 查看 表的定义: DESC tablename 7. 修改 表: ALTER TABLE tablename modify [ COLUMN ] column_definition [ FIRST | AFTER col_name] eg. alter table emp modify ename varchar(20) 修改表emp的ename 字段定义,将varchar(10)改为varchar(20) 8. 增加 表字段: ALTER TABLE tablename ADD [ COLUMN ] column_definition [