dbvisualizer: set max rows in a select query - sql

I am using DBVisualizer 8.0.6 and when I run a simply query like....
select * from table
It only shows the first 1000 rows and then stops the query and displays in the bottom left corner...
"Number of rows limited by maxrows"
How do I change this #? I'm writing a query which needs to export a little over 1000 rows but dbvisualizer has this set limit...
I tried something like
#set maxrows 2000
then commit
then run my query. Still returns only 1000 rows. This is for an Oracle table.

There is a box in SQL Commander labeled Max Rows. Set it to -1 for the complete result set.

Or you could just export directly to a file. This will allow to export many more rows than the DBVisualizer GUI can show you. When having to export a few million records (should you ever need that), this is quite useful.
Simply do something like this in your SQL Commander:
#export on;
#export set Filename="d:\temp\export" format="CSV" DecimalNumberFormat="00000000000" CsvRowDelimiter="\r\n" CsvIncludeColumnHeader="false";
SELECT YOURFIELD FROM YOURTABLE WHERE SOMEFIELD = AFILTERVALUE;
You can find more about this (and the various parameters) here:
http://www.dbvis.com/products/dbvis/doc/7.1/doc/ug/sqlCommander/sqlCommander.html#mozTocId448386

so apparently you need to have DBVisualizer Personal edition to set the maxrows, which the free edition doesn't support. You can get a free trial though. Then you can run something like...
#set maxrows 2000;
select * from table;
If anyone knows how to do this in the free version please feel free to comment, thanks.

From this page, it looks as though the maximum number of rows returned initially is specified within the Tool Properties dialog, on the General Settings tab, on the Table Data node in the Max Rows at First Display property.

select * from table where rownum < 10 would return 9 records for oracle.
But It varies db to db .
Sql server uses select top N fieldName from table.
For MySQL syntax changes as SELECT *FROM table LIMIT N
Maybe Some others use take , skip, etc... So using dbvisualizer , and its setting in the accepted answer is logical for cross db users. It doesn't bother you by varied sql syntax.

Related

sql server shortcut for select statement writing

Many times a day I have to write similar queries to get single record:
select t.*
from some_table t
where t.Id = 123456
maybe there is some shortcuts for retrieving single record? Like entering id, table and SQL server generates rest code automatically
In Sql Server Go to
Tools-> Options-> Environments->Keyboard
You will get shortcuts, there you can define your own as well as get the standards.
you can set a short cut for a fully executable query like
select * from table where id =20
but not like below
select * from

SQL-92 (Filemaker): How can I UPDATE a list of sequential numbers?

I need to re-assign all SortID's, starting from 1 until MAX (SortID) from a subset of records of table Beleg, using SQL-92, after one of the SortID's has changed (for example from 444 to 444.1). I have tried several ways (for example SET #a:=0; UPDATE table SET field=#a:=#a+1 WHERE whatever='whatever' ORDER BY field2), but it didn't work, as these solutions all need a special kind of SQL, like SQLServer or Oracle, etc.
The SQL that I use is SQL-92, implemented in FileMaker (INSERT and UPDATE are available, though, but nothing fancy).
Thanks for any hint!
Gary
From what I know, SQL-92 is a standard and not a language. So you can say you are using T-SQL, which is mostly SQL-92 compliant, but you can't say I program SQL Server in SQL-92. The same applies to FileMaker.
I suppose you are trying to update your table through ODBC? The Update statement looks OK, but there are no variables if FileMaker SQL (and I am not sure using a variable inside query will give you result you expect, I think you will set SortId in every row to 1). You are thinking about doing something like Window functions with row() in TSQL, but I do not think this functionality is available.
The easiest solution is to use FileMaker, resetting the numbering for a column is really a trivial task which takes seconds. Do you need help with this?
Edit:
I was referring to TSQL functions rank() and row_number(), there is no row() function in TSQL
I finally got the answer from Ziggy Crueltyfree Zeitgeister on the Database Administrators copy of my question.
He suggested to break this down into multiple steps using a temporary table to store the results:
CREATE TABLE sorting (sid numeric(10,10), rn int);
INSERT INTO sorting (sid, rn)
SELECT SortID, RecordNumber FROM Beleg
WHERE Year ( Valuta ) = 2016
AND Ursprungskonto = 1210
ORDER BY SortID;
UPDATE Beleg SET SortID = (SELECT rn FROM sorting WHERE sid=Beleg.SortID)
WHERE Year ( Valuta ) = 2016
AND Ursprungskonto = 1210;
DROP TABLE sorting;
Of course! I just keep the table definition in Filemaker (let the type coercion be done by Filemaker this way), and filling and deleting from it with my function: RenumberSortID ().

Get column names of a table in 1 row without data from that table - Firebird

Hello StackOverflow community,
Could you please tell me can I get information about column names of a table in 1 row using Firebird? [*]
What I'd like to achieve is the following using Postgres:
SELECT * FROM table_name LIMIT 0;
Above statement would return 0 rows, but will contain the header
id | data
---+-------
(0 rows)
[*] I need a similar way (taken from example above) in Firebird to obtain information about columns, since I'm using it external tool, so I need to provide a dynamically built schema for dynamic queries. This implies, that I'm not looking for a solution using system tables like rdb$relation_fields.
Adding WHERE condition with dummy value does not apply in my case. I'm looking for something like SELECT FIRST 0 .... Does it even exist?
edited: Yes, it does. Interactive Firebird Client doesn't show up anything, but it does indeed return the "header". This may be confusing for some of us that use psql console which yields 0 rows, but does contain the "header" itself.
Firebird supports limiting the result set - but the syntax is a bit different:
SELECT FIRST 0 *
FROM table_name;
This is part of the Firebird FAQ: http://www.firebirdfaq.org/faq111/
What about this?
select * from (
[any query here]
) where 1=0

Sub-Queries in Sybase SQL

We have an application which indexes data using user-written SQL statements. We place those statements within parenthesis so we can limit that query to a certain criteria. For example:
select * from (select F_Name from table_1)q where ID > 25
Though we have discovered that this format does not function using a Sybase database. Reporting a syntax error around the parenthesis. I've tried playing around on a test instance but haven't been able to find a way to achieve this result. I'm not directly involved in the development and my SQL knowledge is limited. I'm assuming the 'q' is to give the subresult an alias for the application to use.
Does Sybase have a specific syntax? If so, how could this query be adapted for it?
Thanks in advance.
Sybase ASE is case sensitive w.r.t. all identifiers and the query shall work:
as per #HannoBinder query :
select id from ... is not the same as select ID from... so make sure of the case.
Also make sure that the column ID is returned by the Q query in order to be used in where clause .
If the table and column names are in Upper case the following query shall work:
select * from (select F_NAME, ID from TABLE_1) Q where ID > 25

Why does "select count(*)" from nothing return 1

With SQL Server 2012 :
use master
select *
yields
Must specify table to select from
which is exactly what I would expect.
But the funny thing is that
use master
select count(*)
returns 1.
Can someone explain to me what is counted here?
Edit : And possibly include sources...
SQL Server is (behind the curtain) effectively applying a from to a dummy table, which has only one row. Thus you will get 1 for your count.
select 'test'
will do the same thing, as an example, return 'test' one time.
It's like the DUAL table in Oracle, SYSDUMMY1 in DB2, etc.
As requested, here's a couple of links to MS Connect on this topic:
Clicky
More Clicky