08-03-2007
I don't know if this is more efficient, but it seems like a positive approach might be better where there are only a few duplicates.
DELETE FROM tableA A1
WHERE column1 in (SELECT column1 FROM tableA GROUP BY column1 having count(*) > 1)
and rowid != (select min(rowid) from tableA A2 where A1.column1 = A2.column1)
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
My product have around 10-15 programs/services running in the sun box, which together completes a task, sequentially. Several instances of the each program/service are running in the unix box, to manage the load and for risk-management reasons. As of now, we dont follow a strict strategy in... (2 Replies)
Discussion started by: Deepa
2 Replies
2. Filesystems, Disks and Memory
I have some questions regarding disk perfomance, and what I can do to make it just a little (or much :)) more faster.
From what I've heard the first partitions will be faster than the later ones because tracks at the outer edges of a hard drive platter simply moves faster. But I've also read in... (4 Replies)
Discussion started by: J.P
4 Replies
3. Shell Programming and Scripting
How would one go about optimizing this current .sh program so it works at a more minimal time. Such as is there a better way to count what I need than what I have done or better way to match patterns in the file? Thanks,
#declare variables to be used.
help=-1
count=0
JanCount=0
FebCount=0... (3 Replies)
Discussion started by: switch
3 Replies
4. OS X (Apple)
Hi forum,
I'm administrating a workstation/server for my lab and I was wondering how to optimize OSX. I was wondering what unnecessary background tasks I could kick off the system so I free up as much memory and cpu power.
Other optimization tips are also welcome (HD parameters, memory... (2 Replies)
Discussion started by: deiphon
2 Replies
5. Shell Programming and Scripting
Hi,
I have two files in the format listed below. I need to find out all values from field 12 to field 20 present in file 2 and list them in file3(format as file2)
File1 :
FEIN,CHRISTA... (2 Replies)
Discussion started by: nua7
2 Replies
6. Shell Programming and Scripting
Can this awk statement be optimized? i ask because log.txt is a giant file with several hundred thousands of lines of records.
myscript.sh:
while read line
do
searchterm="${1}"
datecurr=$(date +%s)
file=$(awk 'BEGIN{split(ARGV,var,",");print var}' $line)
... (3 Replies)
Discussion started by: SkySmart
3 Replies
7. Shell Programming and Scripting
I have a huge log file close to 3GB in size.
My task is to generate some reporting based on # of times something is being logged.
I need to find the number of time StringA , StringB , StringC is being called separately.
What I am doing right now is:
grep "StringA" server.log | wc -l... (4 Replies)
Discussion started by: Junaid Subhani
4 Replies
8. Shell Programming and Scripting
Hello,
I'm looking for advice on how to optimize this bash script, currently i use the shotgun approach to avoid file io/buffering problems of forks trying to write simultaneously to the same file. i'd like to keep this as a fairly portable bash script rather than writing a C routine.
in a... (8 Replies)
Discussion started by: f77hack
8 Replies
9. Shell Programming and Scripting
now, i have to search for a pattern within a particular time frame which the user will provide in the following format:
19/Jun/2018:07:04,21/Jun/2018:21:30
it is easy to get tempted to attempt this search with a variation of the following awk command:
awk... (3 Replies)
Discussion started by: SkySmart
3 Replies
10. Web Development
Yes.
Got few suggestions.
- How about minifying resources
- mod_expires
- Service workers setup
https://www.unix.com/attachments/web-programming/7709d1550557731-sneak-preview-new-unix-com-usercp-vuejs-demo-screenshot-png (8 Replies)
Discussion started by: Akshay Hegde
8 Replies
LEARN ABOUT PHP
maxdb_affected_rows
MAXDB_AFFECTED_ROWS(3) 1 MAXDB_AFFECTED_ROWS(3)
maxdb_affected_rows - Gets the number of affected rows in a previous MaxDB operation
Procedural style
SYNOPSIS
int maxdb_affected_rows (resource $link)
DESCRIPTION
Object oriented style
int$maxdb->affected_rows ()
maxdb_affected_rows(3) returns the number of rows affected by the last INSERT, UPDATE, or DELETE query associated with the provided $link
parameter. If this number cannot be determined, this function will return -1.
Note
For SELECT statements maxdb_affected_rows(3) works like maxdb_num_rows(3).
The maxdb_affected_rows(3) function only works with queries which modify a table. In order to return the number of rows from a SELECT
query, use the maxdb_num_rows(3) function instead.
RETURN VALUES
An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records where updated for an
UPDATE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the number of
rows affected can not be determined.
EXAMPLES
Example #1
Object oriented style
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s
", maxdb_connect_error());
exit();
}
maxdb_report (MAXDB_REPORT_OFF);
$maxdb->query("DROP TABLE mycustomer");
maxdb_report (MAXDB_REPORT_ERROR);
/* Insert rows */
$maxdb->query("CREATE TABLE mycustomer AS SELECT * from hotel.customer");
printf("Affected rows (INSERT): %d
", $maxdb->affected_rows);
$maxdb->query("ALTER TABLE mycustomer ADD Status int default 0");
/* update rows */
$maxdb->query("UPDATE mycustomer SET Status=1 WHERE cno > 50");
printf("Affected rows (UPDATE): %d
", $maxdb->affected_rows);
/* delete rows */
$maxdb->query("DELETE FROM mycustomer WHERE cno < 50");
printf("Affected rows (DELETE): %d
", $maxdb->affected_rows);
/* select all rows */
$result = $maxdb->query("SELECT title FROM mycustomer");
printf("Affected rows (SELECT): %d
", $maxdb->affected_rows);
$result->close();
/* Delete table Language */
$maxdb->query("DROP TABLE mycustomer");
/* close connection */
$maxdb->close();
?>
Example #2
Procedural style
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
if (!$link) {
printf("Can't connect to localhost. Error: %s
", maxdb_connect_error());
exit();
}
maxdb_report (MAXDB_REPORT_OFF);
maxdb_query($link,"DROP TABLE mycustomer");
maxdb_report (MAXDB_REPORT_ERROR);
/* Insert rows */
maxdb_query($link, "CREATE TABLE mycustomer AS SELECT * from hotel.customer");
printf("Affected rows (INSERT): %d
", maxdb_affected_rows($link));
maxdb_query($link, "ALTER TABLE mycustomer ADD Status int default 0");
/* update rows */
maxdb_query($link, "UPDATE mycustomer SET Status=1 WHERE cno > 50");
printf("Affected rows (UPDATE): %d
", maxdb_affected_rows($link));
/* delete rows */
maxdb_query($link, "DELETE FROM mycustomer WHERE cno < 50");
printf("Affected rows (DELETE): %d
", maxdb_affected_rows($link));
/* select all rows */
$result = maxdb_query($link, "SELECT title FROM mycustomer");
printf("Affected rows (SELECT): %d
", maxdb_affected_rows($link));
maxdb_free_result($result);
/* Delete table Language */
maxdb_query($link, "DROP TABLE mycustomer");
/* close connection */
maxdb_close($link);
?>
The above example will output something similar to:
Affected rows (INSERT): 15
Affected rows (UPDATE): 15
Affected rows (DELETE): 0
Affected rows (SELECT): 15
SEE ALSO
maxdb_num_rows(3), maxdb_info(3).
PHP Documentation Group MAXDB_AFFECTED_ROWS(3)