i have a insert statement pulling data from db link.
insert into table (a,b,c)
select a,b,c from table#mysqldb;
here column c is long type in mysql and in oracle its varchar
i tried to cast as varchar, substr(c, 1,2400), UTL_RAW.CAST_TO_VARCHAR2,dbms_lob.substr
none of them are working on oracle side.
tried cast on mysql read part no use.
Can someone tell me how to do this. Here Iam trying to convert long to varchar. we cannot load as clob as this table is used in many places and we cannot change things at so many places
Thanks.
i had to convert the target column to clob to handle this scenario
Related
I'm trying to find a way to read(select) the data from a table that has a varchar datatype. The data is in Tibetan language. When I query the data it get ???s of different lengths. Surprisingly, when I use the predicate to filter on the string, it does it successfully but the output is still ???. This means that SQL Server is able to understand the filter criteria but it's just not able to show me the output. I'm really not sure what am I missing here.
Let me share the sample here:
--create this table in database with collation set to
--Latin1_General_100_CI_AS or SQL_Latin1_General_100_CI_AS
CREATE TABLE Locations
(Place varchar(64)NOT NULL);
GO
INSERT into Locations_2(Place) VALUES ('ཡུན་རིང་འཇལ་རྒྱུ་མ་བྱུང་།')
INSERT into Locations_2(Place) VALUES ('ཁྱེད་རང་ལུང་པ་ག་ནས་ཡིམ།')
INSERT into Locations_2(Place) VALUES ('ཤོགས་པ་བདེ་ལེགས།')
GO
SELECT place collate Chinese_PRC_CI_AI from locations
where place=N'ཤོགས་པ་བདེ་ལེགས།'
This shows me nothing. But the query below shows the output as ?????????
The only difference is that I am not using N.
SELECT place collate Chinese_PRC_CI_AI from locations
where place='ཤོགས་པ་བདེ་ལེགས།'
I have inserted various Tibetan words and searched them I do get the correct search results but the output is ???????????.
Finally, it all works well when I use the datatype as nvarchar in the create table section above.
This is SQL Server 2008 SP4 on Win server 2008 R2 with latest SP.
I am trying migrate a table from Vertica to Mysql.
I noticed that my table has a Vertica datatype interval.
The column details state that data sub type is Interval Day to Second
A sample data looks like 0 00:49:51.267000
I was wondering if there was a mysql equivalent, if not what could be the best possible match to store the data
There is no equivalent that I know of.
I would just store it in a varchar() by the looks of that character string.
However, if you want to investigate further and see what other data types are available to you here is a good place to start dev.mysql
You could use a TIME(6) type and load it with a VARCHAR version of the interval. You then would be able to do queries like:
SELECT TIME_TO_SEC(field) FROM TABLE;
SELECT MICROSECOND(field) FROM TABLE;
Just depends I guess on what you are trying to do with it.
I have some data in a MySQL table that was mistakenly stored as a float data type. For example:
7.45
I need to convert that data to a decimal type so that I don't run into rounding errors going forward.
If I do this:
ALTER TABLE `invoice_line`
CHANGE `line_quantity` `line_quantity` decimal(18,6) unsigned NOT NULL AFTER `line_rate`;
I end up with values like this in my table:
70.449997
How can I correctly convert the data over to decimal without mangling the data?
I would use something like mysqldump (or MySQL Workbench has a utility as well) to dump the table. Then do your ALTER and recreate it. Just adding precision is going to introduce errors like this because floating point numbers are generally imprecise anyways.
I'm using delphi XE2 and working on a mysql database project.
I have a mysql database which has a table consisting of four columns.
I have two sample rows in this table.
I'm using a TDatabase, TQuery, TDatasource and a TDBGrid to connect to the databse with following source code:
dbgrid1.DataSource :=DataSource1 ;
datasource1.DataSet :=Query1 ;
database1.DatabaseName :='personDatabase';
database1.AliasName :='mysqlodbc';
database1.LoginPrompt :=false;
database1.Connected :=true;
query1.DatabaseName :=database1.DatabaseName;
query1.SQL.Clear;
query1.SQL.Add('select * from persondb.person;');
query1.Active :=true;
the problem is when I try to select all the columns and rows (with select * from persondb.person) and show them in a dbgrid, varchar columns are not being displayed and I only get the two int columns.
It's like varchar columns are not show-able for example the sql select fname from persondb.person will result in two single celled row in dbgrid. the result is the same with sql select fname, lname from persondb.person which is not even logical (cause I expected a 2X2 empty table).
I also changed the character set of the database which was utf8 to latin1 and thought maybe the problem is there but no luck there too.
I googled hours and not even a similar problem to mine. but I leaned that the normal behavior to expect is dbgrid showing varchar fields as (memo) which everyone is trying to overcome.
so any help is appreciated.
It happened to me view days ago. Using dbExpress or Ado connection instead of BDE is not a good idea, because it needs more time to learn and change the code. I use oracle (maybe similiar case with mysql). You should check your database structure.
In Oracle 11, dbgrid cannot display all columns with VARCHAR2 data type and CHAR unit. dbgrid just display data with BYTE unit. but in Oracle 9i, everything's fine.
So, the solution is change the unit (char to byte). Here is the sql statement for oracle :
ALTER TABLE USERX.TABLENAME MODIFY (COLUMNNAME VARCHAR2(50 BYTE));
I have 2 stored procedures Encode,Decode and i want to use this sp to convert my datetime column values (say Dob) to an encrypted date.The problem is that the encrypted format is not in datetime(varbinary) and hence it cant be inserted into that field.Changing the datatype or adding a new column doesn' favour me as my db is a huge one with lots of tables and sps.The steps I use presently is:
declare #datetime
set #datetime='01/02/2008 12:45 PM'
declare #secretDate varchar(400)
declare #date varchar(200)
set #date=(select Convert(varchar(200),#datetime,120)
EXEC #secretDate=dbo.Encode #date
set #date=(select Convert(varchar(200),#secretdate,120))
select Convert(varchar(200),convert(varbinary(MAX),#date)) as EncryptedDate
Any suggestion is appreciated!
You would have to do this change of the column definition in multiple steps.
1) Add a new encryptedDate column set to the encoded value.
2) Drop the existing date column from the table.
3) Rename the encryptedDate to existing date column name.
You may be able to do steps 2 + 3 in one command, but I'm not sure of the syntax.
Any suggestion is appreciated!
This whole thing sounds like a bad idea. If the data is encrypted but the 'Decode' function is a stored procedure in the DB, then the data is effectively not encrypted. Doing this also prevents all data compares from working, which is a Bad Thing.
Why not just encode the data when you read it from the DB if you don't want to present it to users?
Times, and particularly dates have a very unusual, non-linear structure. Even storing dates in structures intended for dates is difficult. If you need to store this data encrypted then don't try to store it in a date / datetime field.