teradata

MACRO to create a table in SQL

江枫思渺然 提交于 2019-12-11 05:21:55
问题 Hi everyone thanks so much for taking the time to read this. I'd like to create a macro in Teradata that will create a table from another table based on specific parameters. My original table consists of three columns patient_id, diagnosis_code and Date_of_birth ...... I'd like to build a macro that would allow me to specify a diagnosis code and it would then build the table consisting of data of all patients with that diagnosis code. My current code looks like this Create Macro All_pats

declaration of variable in teradata

拟墨画扇 提交于 2019-12-11 04:30:10
问题 Is there an equivalent of declaring a variable similar to this Sql Server (TSQL) code in teradata's sql dialect? DECLARE @Somedate Date = GETUTCDATE(); SELECT TOP 10 * FROM SOMETABLE WHERE SOMEDATE = @Somedate; 回答1: Yes and no. You cannot declare variables in a typical SQL Statement that you are running directly from your code editor. You can (as one example) declare variables inside of a stored procedure. In your code editor window, you would be more likely to create a volatile table and use

Teradata: How to back up a table that uses an identity column?

China☆狼群 提交于 2019-12-11 03:42:47
问题 In Teradata, the way I've been doing backups for tables is like this: create table xxx_bak as xxx with data Works great, but I have just discovered that this doesn't work for tables with identity columns. I need a backup method that can duplicate a table with its data intact so that I can roll it back in case I mess up some data. 回答1: If you just want a copy of the table, you can create one with the same structure but without making the key column an identity column. You can then insert into

How to load data from a csv file into a table using Teradata Studio [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-11 03:38:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . Hi everybody, someone here may help me on that? I have to load data from a csv file into a table but I have no idea how. There are about 12 million records into the csv file. thanks 回答1: I have loaded data into Teradata using the IMPORT function available in the TERADATA SQL

Unable to connect to Teradata from excel using VBA code - Teradata Server can't be reached over the network

谁说我不能喝 提交于 2019-12-11 02:14:40
问题 I have been trying to connect to Teradata from Excel using vba code but I am getting the below mentioned error: Teradata Server can't be reached over the network. I have been able to successfully connect from Teradata SQL assistant and I also successfully pinged the Teradata server(I am using Teradata express edition in my laptop which runs on VMware player). I also successfully connected to Teradata from Excel Data connection wizard and Microsoft query. I have also switched off the firewall

select aggregate function and all other columns

喜你入骨 提交于 2019-12-11 01:46:16
问题 How do I select all columns in a table and an aggregate function in a convenient way? I.e. say that I have a table with 100 columns, and I want to send the following SELECT Max(Columns 44), ALL OTHER COLUMNS FROM zz Group by ALL OTHER COLUMNS Thanks! 回答1: To select all columns from the table is: select * from zz; To select a maximum from the table is select max(column44) from zz; The two combined: select zz.*, (select max(column44) from zz) as maxcol44 from zz; If you want to omit column44 in

Teradata Drop Column returns with “no more room”

狂风中的少年 提交于 2019-12-10 23:40:14
问题 I am trying to drop a varchar(100) column of a 150 GB table (4.6 billion records). All the data in this column is null. I have 30GB more space in the database. When I attempt to drop the column, it says "no more room in database XY". Why does such an action needs so much space? 回答1: This could happen for a variety of reasons. It's possible that one of the AMP's in your database are full, this would cause that error even with a minor table alteration. try running the following SQL to check

Quicken upload of 3000 inserts into Teradata via VBA

点点圈 提交于 2019-12-10 23:08:22
问题 Thank you so much to the answer from jacouh (VBA Copy & Paste 3000 rows) to my initial problem. With the help of the forum, I now have the below code, which inserts 2999 rows from an Excel file. Each row is INSERT (X, Y, Z, ...) VALUES (X1, Y1, Z1,...) into DBNAME.TABLE . Whilst it works, it is painfully slow. As I understand, I could increase the speed of the inserts by increasing the size of the buffers, as described in http://developer.teradata.com/doc/connectivity/tdnetdp/13.11/webhelp

Teradata string truncated after UNION ALL

蹲街弑〆低调 提交于 2019-12-10 20:48:33
问题 I have a query with a UNION clause. One of the field is a plain hardcoded string. The string in the statement after UNION gets truncated to match the string length of the field before the UNION. Sounds confusing? Here's an example. SELECT 'abc' as xxx FROM tbl1 UNION ALL select 'defghi' as xxx FROM tbl2; For the above query, I would expect the output to be abc defghi However, the output is abc def Any thoughts? EDIT : The workaround, I am aware of currently is to have the SELECT statement

Get column type using teradata system tables

余生颓废 提交于 2019-12-10 16:10:34
问题 I want to get the actual column type from teradata system tables like dbc.columns. This table have column columntype but it does not give the actual datatype. I can get output with select type(columnname) from table output: varchar2(20) but there are 1000 tables and 50000 columns. Please suggest some query that can give me actual column type of column from metadata itself 回答1: For views the columntype will be NULL, because it's resolved at runtime. For a single table you can do a HELP COLUMN