Am 28.03.21 um 23:27 schrieb Benoit Xhenseval via Squirrel-sql-users:
> Hi
>
> I love Squirel/J, thanks for the great tool.
thank you.
>
> I was looking for a way to guess the table size and I found a screen
> that shows the Column Size.
>
> I thought I could just add each column size to have a good guess.
>
> Some of my columns are BIGINT and the col size is 64 which implies it is
> in Bits, as expected. But then I can see some varchar(80) and 20 and the
> col Size is 80 and 20, implying in BYTES.
>
> What is the unit on the Column Size? It is the same for each data
> type? Or is it a small bug?
It's up to the JDBC driver to deliver the sizes. Below's a small Java
program that shows how sizes are read. You may use it to reproduce your
problem and possibly to consult your JDBC driver or database vendor.
Gerd
public class ResultSetTest
{
public static void main(String[] args)
throws ClassNotFoundException, SQLException
{
Class.forName("<YourJDBCDriverName>");
Connection con = DriverManager.getConnection("<YourJDBCUrl>",
"User", "Password");
ResultSet column =
con.getMetaData().getColumns(null,
"<YourSchemaOr_null>",
"<YourTableName>",
"<YourColumnName");
column.next();
int size = column.getInt("COLUMN_SIZE");
System.out.println("Column size is: " + size);
}
}
|