Sync only especifics columns in SymmetricDS - symmetricds

This is my table:
ITEM_PRECO_VENDA (
ID_ITEM,
ID_LOJA,
PRECO,
CUSTO,
CIDADE)
I want to replicate only the column CIDADE, how can i do this?
Please, help.

I found how to do: On table SYM_TRIGGER it has the column INCLUDED_COLUMN_NAMES you put the columns that you want to replicate, and it will ignore the others.

Related

How to get row count of VIEW table along with Metadata information in Snowflake?

I would like to get row count of VIEW table in Snowflake along with metadata information such as TABLE_SCHEMA,TABLE_NAME,CREATED,LAST_ALTERED columns from INFORMATION_SCHEMA for the specific VIEW table.Let say my VIEW table name is "V_TEST"
I can write SELECT COUNT(*) FROM DB.SCHEMA.V_TEST and get a row count for VIEW table but not sure how to merge in the table with metadata table ?
I can get TABLE_SCHEMA,TABLE_NAME,CREATED,LAST_CREATED using below code
SELECT TABLE_SCHEMA,TABLE_NAME,CREATED,LAST_CREATED FROM DB.Information_SCHEMA.VIEWS
WHERE TABLE_NAME='V_TEST'
Thanks in advance for your help and efforts!

Snowflake insert into table column

How can I insert into a table array column without using a select:
insert into demo.array_table
select array_construct(array_construct('cars','motorcycles','trucks','vans'),1);
I can't seem to use VALUES().
You need to use the SELECT for Array column.
More details in Docs: https://docs.snowflake.com/en/sql-reference/data-types-semistructured.html#examples
A couple of examples are listed in the article: https://community.snowflake.com/s/article/How-to-use-an-INSERT-statement-to-add-an-ARRAY-column-to-the-table

Eliminate unsed rows when making select query

I have a big database, I get about 100.000 data for a day, and database is getting bigger fastly
when I make a select query for last added rows , select query looking all datas in tables.
For example;
Select ... WHERE INSERT_TIME > TO_TIMESTAMP('27/11/2014 16:12:09,383418' , 'DD/MM/YYYY HH24:MI:SS,FF')
this query look at all rows if it is added after that time or not. But I will just use last added rows so I dont wanna look at all rows if it is new or not. that is I want to eliminate all rows which I used before when searching the table for new entries.
Additionaly I dont wanna create any new table for this and dont wanna delete any rows from the table
Is there any way or solution for this?
Thank you advance!

SQLite 3 copy data from old table into new table

I have two tables with identical structure which I need to copy several columns from one to the other. Something like this:
* UPDATE **
Apparently I need to update the new table. I want to copy the data from the old table into the new table for each record that the name matches. I'm not sure what command to use. Here is an approximation:
copy from OLDTABLE columns category, key into NEWTABLE when the names match
Any help or suggestions would be appreciated. Thanks in advance!
Your query does not have proper syntax. It has two select clauses, the second of which does not have a from:
insert into newdata
select category, key
from olddata
select category, key
where olddata.name = newdata.name
I am guessing that you want something like:
insert into newdata(cateogry, key)
select olddata.category, olddata.key
from olddata
where olddata.name
Do you really want an insert, or are you looking for an update?

SQL Server : insert a new row as ID of 1

I have a table called ComplaintCodes which contains about 15 rows and 2 columns: ComplaintCodeId and ComplaintCodeText.
I want to insert a new row into that table but have its ID set to 1 which will also add 1 to all of the ID's that exist already. Is this possible?
EDIT
Using SQL Server and ComplaintCodeId is an identity / PK column
It's possible as two separate DML statements, an UPDATE to update the ID and a subsequent INSERT. But this will fail if you are using the ID as a foreign key in another table of course, so you'd need to find a way to update across all related tables.
Why would you want to do this though? Suggest you take a step back and reconsider the design decision that has brought you to this question.
And yes, as podiluska says in his/her(/its!) comment, please specify which DBMS you are using in your question and/or tags.
update <table> set ComplaintCodeId =ComplaintCodeId +1
insert into <table>
select 1,'other column'
Edit:
If its a PK+Identity column, then its a very bad idea to do like this. You cannot update an identity column..
Instead of updating you could do something like this:
select row_number() over (order by ComplaintCodeId desc) as row_num,
ComplaintCodeId
from table
and use row_num instead of ComplaintCodeId
After some thought, it seems to me that the best solution to your problem is to change the PK to be non-identity. Then you can set the value to whatever you'd like.
I still think that using a Display Order column (which is the only reason I can think you'd care the order in the table) would be a fine solution, but if you really want the PK order to be the display order, then changing the PK to non-identity would be a good long-term solution as you wouldn't have these problems in the future.

Resources