I have a data table in SQL which is using decimal to record IP addresses for the computers.
Any SQL command will be work for query them into address?
The data in the table is 3232235777 and the expected output should be 192.168.1.1
Based off of the example you've given, you won't be able to convert that string of numbers( or decimal ) into any meaningful IP address entry. The column would need to be some type of VarChar or Nvarchar. But the difficulty would be creating the correct mask to parse out the IP address.
Related
When querying columns that are a Postgres domain type using JDBC (with driver https://jdbc.postgresql.org/ version 42.3.3), there doesn't seem to be any way of getting the domain information; only the underlying datatype is reported.
create domain account_uuid_type as uuid;
create domain customer_uuid_type as uuid;
create table test (
account_uuid account_uuid_type,
customer_uuid customer_uuid_type
);
insert into test
(account_uuid, customer_uuid)
values
(
'4c1210c2-e785-4462-926c-1789cd1aa88c',
'b155e10c-10cd-4a11-b427-d7c78397b617'
);
When querying the table from Java using select account_uuid, customer_uuid from test, the information from the PgResultSet is that the pgType values for the columns is uuid. There's no mention of the more specific domain information. Is there a way of asking Postgres to add the domain information into the metadata?
I am creating a DDL file to be deployed as VDB using TEIID.
The source model is MS SQl. In the source database there is geography data type column. I am trying to read the lat and long from geography data type.
To retrieve the lat/long in sql server:
db.geogCol.Lat
db.geogCol.Long
When creating a view in ddl file using select statement and trying to retrieve the lat/long by passing to teiid, an exception is thrown. Teiid seems to think .Lat and .Long are columns whereas they are sql server function tied to the geography data column. How can i execute this so it treats the above arguments as ms-sql
The closest representation is a source function. You will need to create source functions to represent them. On the sql server schema:
create foreign function lat (geography geog) returns double
OPTIONS ("teiid_rel:native-query" '$1.Lat');
and a similar one for Long.
Teiid does have the st_x and st_y functions, but I don't think they are eligible for pushdown to sql server currently.
I am using PostgreSQL backend with linked tables in Access. On using the wizard to link to the linked tables, I get errors:
Scaling of decimal value resulted in data truncation
This appears to be the wrong scale for numeric data types being chosen as the default by Access: the Postgresql data type being linked is Numeric with no precision or scale defined, and is being linked as Decimal with precision 28 and scale 6 as default.
How can I get Access to link it as Double?
I see here MS Access linked tables automatically long integers that the self-answer was:
Figured it out (and I feel dumb): When linking tables you can choose
the desired format for each field when going through the linked table
wizard steps.
But, I see no option in Access to choose the desired format during linking.
If there is anything like a "default" data type when creating an ODBC linked table in Access, that type would be Text(255). That is, if the ODBC driver reports a column with a data type that Access does not support (e.g. TIME in SQL Server) then Access will include it as a Text(255) column in the linked table.
In this case, for a PostgreSQL table
CREATE TABLE public.numeric_test_table
(
id integer NOT NULL,
text_col character varying(50),
numeric_col numeric,
CONSTRAINT numeric_test_table_pk PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
the PostgreSQL ODBC driver is actually reporting the numeric column as being numeric(28,6) as confirmed by calling OdbcConnection#GetSchema("columns") from C#
so that is what Access uses as the column type for its linked table. It is only when Access goes to retrieve the actual data that the PostgreSQL ODBC driver sends back values that won't "fit" in the corresponding column of the linked table.
So no, there is almost certainly no overall option to tell Access to treat all numeric (i.e., Decimal) columns as Double. The "best" solution would be to alter the PostgreSQL table definitions to explicitly state the precision and scale, as suggested in the PostgreSQL documentation:
If you're concerned about portability, always specify the precision and scale [of a numeric column] explicitly.
If modifying the PostgreSQL database is not feasible then another option would be to use a pass-through query in Access to explicitly convert the column to Double ...
SELECT id, text_col, numeric_col::double precision FROM public.numeric_test_table
... bearing in mind that pass-through queries always return read-only recordsets.
I have to transfer data from old database to new database where table name and column name is different.
Can it be done with DOS command or any other solution?
One is POSTGRESQL and old is MYSQL.
My concern is table name and column names are different, column number is same.
Thank you
I do not know the postgresql part but for sql server you can use sqlcmd.exe to export data as text format with or w/o column names
Please check
http://msdn.microsoft.com/en-us/library/ms162773.aspx
We are SQL Server users and recently we have one database on PostgreSQL. For consistency purpose we are replication database on SQL Server 2000 to other database on SQL Server 2000 and now we would also need to replicate it to the database on PostgreSQL. We were able to do that using ODBC and Linked Server. We created an ODBC DSN for database on PostgreSQL and using that DSN we created a Linked Server on SQL Server. We were able to replicate tables from SQL Server database to that linked server and hence to PostgreSQL database successfully. Now the issue faced is while replication, the datatype bit, numeric(12,2) and decimal(12,2) are converted to character(1), character(40) and character(40) respectively. Is there any solution on how to retain those data types in PostgreSQL database ? I mean the bit should become boolean, and numeric and decimal data type should remain as it is in the replicated table of postgresql. We are using PostgreSQL 9.x
SQL Server table,
CREATE TABLE tmtbl
(
id int IDENTITY (1, 1) NOT NULL PRIMARY KEY,
Code varchar(15),
booleancol bit,
numericcol numeric(10, 2),
decimalcol decimal(10, 2)
)
after being replicated to PostgreSQL it becomes,
CREATE TABLE tmtbl
(
id integer,
"Code" character varying(15),
booleancol character(1),
numericcol character(40),
decimalcol character(40),
)
Thank you very much.
Please, use:
boolean type for true/false type of columns (there's no bit type in postgres);
NUMERIC type exists also in the PostgreSQL (according to the SQL standard). But I suggest you should better use real PostgreSQL type, as it will be working faster.
I recommend you to create target table on the PostgreSQL side manually, specifying proper field types, as ODBC+Linked Server combination is not doing it's job properly.
You can always consult this part of the official documentation for existing data types.
have you heard of Foreign Data Wrappers?
http://wiki.postgresql.org/wiki/Foreign_data_wrappers