Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to delete data on table
Old 12-20-2008, 10:16 AM How to delete data on table
Average Talker

Posts: 27
Trades: 0
Hi folks,


I mistakenly entered "dbPerdition" on db table of MySQL


mysql> SHOW tables;
Code:
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
17 rows in set (0.00 sec)
mysql> SELECT * from db;
Code:
+-----------+-------------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
| Host      | Db          | User      | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv |
+-----------+-------------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
| localhost | maildb      | mail      | Y           | Y           | Y           | Y           | Y           | Y         | N          | N               | N          | N          | N                     | N                | N                | N              | N                   | N                  | N            |
| %         | maildb      | mail      | Y           | Y           | Y           | Y           | Y           | Y         | N          | N               | N          | N          | N                     | N                | N                | N              | N                   | N                  | N            |
| localhost | dbPerdition | perdition | Y           | Y           | Y           | Y           | Y           | Y         | N          | N               | N          | N          | N                     | N                | N                | N              | N                   | N                  | N            |
| %         | dbPerdition | perdition | Y           | Y           | Y           | Y           | Y           | Y         | N          | N               | N          | N          | N                     | N                | N                | N              | N                   | N                  | N            |
+-----------+-------------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+
4 rows in set (0.00 sec)
Please advise how to drop it. TIA


B.R.
satimis
satimis is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-20-2008, 12:14 PM Re: How to delete data on table
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
First thing, take 30 minutes to educate yourself with this simple and concise sql primer. http://blog.dmbcllc.com/2008/09/18/b...r-programmers/








and then only:
Code:
 delete from db where Db='dbPerdition' and user='perdition'
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-22-2008, 04:06 AM Re: How to delete data on table
Average Talker

Posts: 27
Trades: 0
Quote:
Originally Posted by tripy View Post
First thing, take 30 minutes to educate yourself with this simple and concise sql primer. http://blog.dmbcllc.com/2008/09/18/b...r-programmers/

and then only:
Code:
 delete from db where Db='dbPerdition' and user='perdition'
Noted with thanks.


B.R.
satimis
satimis is offline
Reply With Quote
View Public Profile
 
Old 12-22-2008, 12:53 PM Re: How to delete data on table
Average Talker

Posts: 22
Name: Tim
Trades: 0
As others said.

A good place would be to goto www.mysql.com as they explain all of that
__________________

Please login or register to view this content. Registration is FREE

VPS Special: $9.95 / 10Gig HD | 150GB Bandwidth
Please login or register to view this content. Registration is FREE

Shared hosting: $3.45 / 10Gig HD | 100GB Bandwidth
Please login or register to view this content. Registration is FREE
GixxerPC is offline
Reply With Quote
View Public Profile
 
Old 12-22-2008, 09:58 PM Re: How to delete data on table
Average Talker

Posts: 27
Trades: 0
Quote:
Originally Posted by GixxerPC View Post
As others said.

A good place would be to goto www.mysql.com as they explain all of that
Hi GixxerPC,


Thanks for your link.


Previously googling brought me many mysql doc.,

such as;
http://dev.mysql.com/doc/refman/5.0/en/update.html

I'm not well understood some expression.

E.G.
{expr1|DEFAULT}
where_condition

table_references

etc.


Are there example links? TIA


B.R.
satimis
satimis is offline
Reply With Quote
View Public Profile
 
Old 12-23-2008, 03:44 AM Re: How to delete data on table
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
I'm not well understood some expression.

E.G.
{expr1|DEFAULT}
where_condition

table_references

etc.


Are there example links? TIA
That, I can understand, let take an example:
Quote:
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
For the conventions, in almost every programming doc I have seen, what is contained between [ and ] is optionnal.
What is contained bewteen { and } denote that you have a choice, and each choices is delimited by |

Something like
Code:
[, col_name2={expr2|DEFAULT}] ...
should be read "separate each column to be updated by a comma, and add as much as you need to the query".
As they are between [], it means that it's not mandatory, which is logical.

The WHERE clause is the filter. It's where you will tell to the sql engine what conditions should the rows have to be elected to be updated.

And the LIMIT statement is pretty self explanatory, it allows you to apply that update to the x first elements only.
That one is generally used with the ORDER BY statement, to ensure that the order of the rows is known.
Otherwise, you cannot be assured of the rows order.

So, in this example, it means that the smallest query that you can write is
Code:
UPDATE tbl_name
SET col_name1=value1
But you could end up with
Code:
UPDATE LOW_PRIORITY tbl_name
SET col_name1=value1, col_name2=value2, col_name3=value3, col_name4=value4, col_name5=DEFAULT, col_name6=value7
WHERE enabled=1 
AND creation_date between '2006-01-01' and '2006-03-01'
AND EXISTS (
  SELECT 1
  FROM other_table
  WHERE id=tbl_name.id 
  AND status='paid'
)
Which, will being more complex, is still pretty understandable, I think.
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 12-23-2008 at 03:53 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to How to delete data on table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.81706 seconds with 12 queries