I have DevCenter 1.2.1.Some CQL commands working well but COPY command is not working.It shows error message "You made a type...sorry typo".Any hint???
The copy command, as well as some other commands are unique to cqlsh only and not part of the CQL spec proper, so they cannot be used in DevCenter.
Source: https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/JQXF99YAB_E (what applies to drivers also applies to DevCenter)
While DevCenter does not support cqlsh specific commands such as COPY, it does allow you to copy results of a query from the Results view in either a CSV or INSERT statement format.
For CSV, execute your query and select the rows you want to copy in the Results view, then right-click and select "COPY as CSV". You can also select "COPY All as CSV" as a shortcut if you want all rows from the result set. This will copy all the result data to the clipboard and the format of this data should be compatible with cqlsh COPY. You can paste this data into a file to get a result similar to COPY TO in cqlsh.
You cannot directly achieve the same thing as cqlsh COPY FROM in DevCenter, however the "Copy [All] as INSERT" option provides the ability to generate INSERT statements from a given query result set to the clipboard which can then be pasted back into the editor and executed again. For small data sets, this method can be a convenient to create a script to load data for testing or backup.
Related
I have some external csv/txt files and I'd like to use them for a pivot table.
However, after I selected my csv file as the external data source, at the end of the guided procedure (header, seperators, etc.) Excel throws an error saying something along the lines of: it's impossible to use the selected type of connection for a pivot table.
Now, I know how to do it with another excel/db table - here it would come very handy to use a csv/txt file.
Can this be done natively, without external plugins?
Use the keyboard shortcut Alt, D, P (not all at once like Alt+D+P, but press each one seperatly). This brings up the old-style pivot table wizard.
Select External Data Source
Click Get Data
Choose and click OK.
Name your data source and choose Microsoft Access Text Driver
Click Connect, uncheck Use Current Directory (unless that's what you want), and Select the Directory you want.
If you don't identify the file when you get back to the "Select a default table..." text box, you'll get prompted to select one.
At that point, click OK back through the dialog boxes. Eventually you'll get thrown into MSQuery where you can build the query you want. From there Return Data to Excel and you can build your pivot table.
I have a stored procedure that returns formatted, delimited text using dbms_output.put_line statements. Currently, we run the script in Toad and manually paste the output into Excel, but I was hoping I could cut out a step and get the output directly into Excel. I created a connection and set the properties to run the SP: that works fine (more or less -- the next step would have been to figure out how to supply a parameter). However, since no query is being returned, Excel doesn't recognize that there's anything to be done. Is there any way to do this automagically? Thanks.
ETA: I was just trying to figure out if I could build a cursor by inserting the GET_LINE output into it and return that, but that didn't look like it was going to work out.
If you are using Toad most recent versions (10+) allow you to save your output as an excel file. Earlier versions also allow this but with different commands.
In the output section at the bottom right click on any part of the results:
select "Export Dataset".
select your choice of export file (Excel file)
select a file path and file name
choose whatever options such as saving the sql on a separate worksheet you need
press the button in the lower right corner
Even if the output is comma delimited csv you can then have excel convert it into a real xls or xlsx format.
How do I insert data into a columm with the type TEXT in Informix via SQL. If there are two other columns that I also want to insert/update - is the only way to save it in a file and LOAD it?
Or if I want to do do via SQL statements - can you give the syntax?
See my question: Consistent method of inserting TEXT column to Informix database using JDBC and ODBC
It is easy with JDBC and PreparedStatement. ODBC works little different but is able to insert string with simple SQL INSERT (without preparing).
The load command works, and you can also use ESQL/C to do it (it is mentioned in this answer that you might already found).
About doing it in a simple insert,
You can use the VALUES clause to insert a value, but the only value that you can give that column is null. However, you can use the SELECT form of the INSERT statement to copy a TEXT or value from another table.
You can see here the docs for Text data type.
I used MS SQL Server 2008 R2 (MS SQL) where I could right click the query result, copy/paste it with headers to Excel for easy exploration. Now with PG Admin (PostgreSQL) I have to do export (File > Export > CSV) then bunch of Excel steps (Text To Columns).
Is there an easy way to copy/paste the query result with headers into Excel?
For pgAdmin 4, there is an option to "Copy with headers". It is a drop-down beside the copy button in the Query Tool menu:
PgAdmin seems to make semi colon the default field separator. Excel seems to like tabs by default.
You could try and change excel or each time just do the "text to columns" feature.
I personally would go to Preferences->Query tool->Results grid and change the following
Result copy quote character: "
Result copy field separator: Tab
Copy column names: True
This will make it more behave more like sql management studio.
There's a lot of different ways to accomplish what you want here. The question is a bit confusing because you are talking about Excel, but then you table about '/var/lib/postgres/myfile1.csv', which makes me think you are now using some favor of Linux.
I'm using Ubuntu 12.04 with pgAdminIII 1.16.0. And I have Open Office installed with LibreOffice 3.5.4.2 as the Excel replacement.
I'm not sure why you want to take the information out of the grid in pgAdminIII, but assuming just wanting to take the data and move it over to a spreadsheet to play it for some reason, then about the easiest way to do it is run your query and click the upper left corner of the results (which just like a spreadsheet selects everything) and copy. Then, you should be able to open LibreOffice and paste in the information. It will bring up the same dialog as you would see when importing a CSV file.
Also, you should be able to start psql and then do a "COPY" command. If you get a permissions error, then try the suggested "\COPY" instead. Please see the PostgreSQL docs. Here is a link to a wiki page here.
If I'm missing what you are trying to do, please ask questions in the comments section, and I'll try to improve my answer accordingly.
You have to set your query tool output to text not the grid data. That way the Column names and the query results are all in the same cut past text file. When you do this you are no longer doing CSV. The whole results and field names comes over as a text file in the cut and paste process.
Answering to quite an old post:
The answer by #Phillip Fleischer seems to be the best way, at least in pgAdmin III. But for pgAdmin III version 1.22.2 (the one I am using), instead of Preferences..., the settings mentioned were seen under File > Options > Query tool > Results grid.
I've inherited a Sybase database that has the 'unique auto_identity index' option enabled on it. As part of an upgrade process I need to add a few extra columns to the tables in this database i.e.
alter table mytable add <newcol> float default -1 not null
When I try to do this I get the follow error:
Column names in each table must be unique, column name SYB_IDENTITY_COL in table #syb__altab....... is specifed more than once
Is it possible to add columns to a table with this property enabled?
Update 1:
I created the following test that replicates the problem:
use master
sp_dboption 'esmdb', 'unique auto_identity indexoption',true
use esmdb
create table test_unique_ids (test_col char)
alter table test_unique_ids add new_col float default -1 not null
The alter table command here produces the error. (Have tried this on ASE 15/Solaris and 15.5/Windows)
Update 2:
This is a bug in the Sybase dbisql interface, which the client tools Sybase Central and Interactive SQL use to access the database and it only appears to affect tables with the 'unique auto_identity index' option enabled.
To work around the problem use a different SQL client (via JDBC for example) to connect to the database or use isql on the command line.
Should be no problem to ALTER TABLE with such columns; the err msg indicates the problem regards something else. I need to see the CREATE TABLE DDL.
Even if we can't ALTER TABLE, which we will try first, there are several work-arounds.
Responses
Hah! Internal Sybase error. Open a TechSupport case.
Workaround:
Make sure you get jthe the exact DDL. sp_help . Note the IDENTITY columns and indices.
Create a staging table, exactly the same. Use the DDL from (1). Exclude the Indices.
INSERT new_table SELECT old_table. If the table is large, break it into batches of 1000 rows per batch.
Now create the Indices.
If the table is very large, AND time is an issue, then use bcp. You need to research that first, I am happy to answer questions afterwards.
When I ran your sample code I first get the error:
The 'select into' database option is not enabled for database 'mydb'. ALTER TABLE with data copy cannot be done. Set the 'select into' database option and re-run
This is no doubt because the data within your table needs copying out because the new column is not null. This will use tempdb I think, and the error message you've posted refers to a temp table. Is it possible that this dboption has been accidentally enabled for the tempdb?
It's a bit of a shot in the dark, as I only have 12.5 to test on here, and it works for me. Or it could be a bug.