insert-update

SQL Server columnstore index update/insert in stored procedure

不问归期 提交于 2019-12-10 20:57:39
问题 I was having fun testing out the columnstore index feature of sql server 2012. Because you can't update/insert tables with such indices I read on some options: keep a separate table and use a new partition for every bulk insert or disable the index, perform updates/inserts and then rebuild the index. For my test I chose the latter option and ended up with this stored procedure: -- Disable the columnstore index. ALTER INDEX [All_Columns_Columnstore_Index] ON [dbo].[Tick] DISABLE -- Insert data

Is JDBC multi-threaded insert possible?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 15:08:51
问题 I'm currently working on a Java project which i need to prepare a big(to me) mysql database. I have to do web scraping using Jsoup and store the results into my database as well. As i estimated, i will have roughly 1,500,000 to 2,000,000 records to be inserted. In my first trial, i just use a loop to insert these records and it takes me one week to insert about 1/3 of my required records, which is too slow i think. Is it possible to make this process multi-threaded, so that i can have my

Use“ INSERT … ON DUPLICATE KEY UPDATE” to insert multiple records

∥☆過路亽.° 提交于 2019-12-10 14:28:07
问题 My Table structure table: marks My objective: i want to insert or update multiple records with the condition i am currently check by this query 1st step SELECT * FROM `marks` WHERE `student` =115 AND `param` =1 2nd step if records found by matching above criteria i just update record by my new values else insert new record into my table It gonna working fine . but i want to reduce code and optimize this into single query . its possible or not ? I found this on MySQL docs INSERT ... ON

How to update a table from one server to another?

◇◆丶佛笑我妖孽 提交于 2019-12-10 12:16:50
问题 I need to do an update from one server to another and could only get to the code that are below. I wanted to know where the mistake is. If separating the codes works perfectly. <?PHP $db_host1 = "10.0.0.101"; $db_user1 = "dns"; $db_password1 = "123456"; $db_name1 = "dns"; $db_connect1 = mysqli_connect($db_host1, $db_user1, $db_password1, $db_name1); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $db_host2 = "10.0.0.102"; $db_user2 = "dns"; $db

Is there a way to do an “INSERT…ON DUPLICATE KEY UPDATE” in Zend Framework 1.5?

前提是你 提交于 2019-12-09 04:05:37
问题 I would like to use ON DUPLICATE KEY UPDATE in Zend Framework 1.5, is this possible? Example INSERT INTO sometable (...) VALUES (...) ON DUPLICATE KEY UPDATE ... 回答1: I worked for Zend and specifically worked on Zend_Db quite a bit. No, there is no API support for the ON DUPLICATE KEY UPDATE syntax. For this case, you must simply use query() and form the complete SQL statement yourself. I do not recommend interpolating values into the SQL as harvejs shows. Use query parameters. Edit: You can

PHP PDO simple insert or update function

北城余情 提交于 2019-12-09 03:34:13
问题 In trying to create a simple PHP PDO update function that if the field is not found would insert it, I created this little snippet. function updateorcreate($table,$name,$value){ global $sodb; $pro = $sodb->prepare("UPDATE `$table` SET value = :value WHERE field = :name"); if(!$pro){ $pro = $sodb->prepare("INSERT INTO `$table` (field,value) VALUES (:name,:value)"); } $pro->execute(array(':name'=>$name,':value'=>$value)); } It does not detect though if the update function is going to work with

Insert into h2 table if not exists

本小妞迷上赌 提交于 2019-12-08 14:48:59
问题 I am using H2. I want to insert a value into a table if it does not exist. I create the table with: CREATE TABLE IF NOT EXISTS $types (type VARCHAR(15) NOT NULL UNIQUE); And I want to do something like REPLACE INTO types (type) values ('type1'); I found an example about Replace that apparently works for MySQL but I am using h2. But I get an error when I run this from my h2 console: Syntax error in SQL statement "REPLACE[*] INTO TYPES (TYPE) VALUES ('expense') "; expected "ROLLBACK, REVOKE,

how to update table using api in codeigniter

China☆狼群 提交于 2019-12-08 06:03:57
问题 I'm stuck at updating table row using api in codeigniter, i already have read tutorial from code tutsplus but there's no spesific to do it, so i tried by myself and got stuck :-( url request: http://localhost/work/bnilife/v1/signup/user/post?nopol=a1b2c3d4e5&username=agus&password=kucingtikus&captcha=c12ds Here's the json respon: { "error": "error :-( " } My Controller look like this below: public function user_post() { date_default_timezone_set('Asia/Jakarta'); $datestring ="%Y-%m-%d %H:%i:

Update using left join in netezza

≯℡__Kan透↙ 提交于 2019-12-07 09:01:13
问题 I need to perform a left join of two tables in netezza during an update. How can i achieve this ? Left join with three tables are working but not with two tables. UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 LEFT JOIN table_3 t3 ON t2.c1=t3.c1 this works but UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 this says like trying to update multiple columns. Thanks, Manirathinam. 回答1: When performing an UPDATE TABLE with a

update on duplicate key with JdbcBatchItemWriter

匆匆过客 提交于 2019-12-06 02:10:17
spring Batch for my project, and I'm simply trying to read from a csv file and load data to a database, using JdbcBatchItemWriter as writer. I'm looking for a way to tell the writer to insert a new row, but, on duplicate key (or duplicate unique identifier) update row instead of failing. I know I can do that directly in the sql statement, but that would be specific to Mysql, though I want my code to be DBMS-independent. here is my writer declaration in the java config @Bean @StepScope public ItemWriter<Person> writerHeadingCollectionsToDb(DataSource datasource) { String sqlStatement = "INSERT