1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to delete all table's data

Discussion in 'Databases' started by getbestproduct, Dec 23, 2010.

  1. mmerlinn

    mmerlinn Prominent Member

    Messages:
    2,800
    Likes Received:
    638
    Best Answers:
    6
    Trophy Points:
    320
    #41
    Hijacking threads will not get you the quality answers that you seek. You will get more and better answers by starting your own thread.
    SEMrush
     
    mmerlinn, Jan 13, 2012 IP
    SEMrush
  2. andyrobert877

    andyrobert877 Greenhorn

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #42
    You can delete all data of a table with the use of following command
    SQL> delete * from table_name
     
    andyrobert877, Jan 19, 2012 IP
  3. bonzoi

    bonzoi Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #43
    Use truncate commend to delete all table contents from table.
     
    bonzoi, Sep 12, 2012 IP
  4. sigmainfo

    sigmainfo Active Member

    Messages:
    495
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    55
    #44
    select 'delete from ' + o.name + ';'
    from sysobjects o,
    sysusers u
    where o.type = 'U'
    and o.uid = u.uid
    and upper(u.name) = 'xxx';
     
    sigmainfo, Sep 12, 2012 IP
  5. ratan1980

    ratan1980 Member

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    28
    #45
    delete from yourtablename; will delete all data.
     
    ratan1980, Sep 13, 2012 IP
  6. sywids

    sywids Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #46
    -------------------in Visual Basic : ---------------------

    dim conn As ADODB.Connection
    dim ConnString as string

    ConnString="DRIVER={MySQL ODBC 3.51 Driver};SERVER=myServer;DATABASE=myDatabase;UID=admin;PWD=myPassword;PORT=3306;OPTION=3"

    Set conn = New ADODB.Connection
    conn.ConnectionString = ConnString
    conn.CursorLocation = adUseClient
    conn.Open

    '--------------The table name is Perkiraan--------------------

    conn.execute "Delete * from Perkiraan"
     
    sywids, Sep 17, 2012 IP
  7. Sarah Reece

    Sarah Reece Greenhorn

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #47
    Though both DELETE and TRUNCATE can be used to accomplish the task of emptying a database table, You may want to consider performance and undo space and other factors. Remember that Truncate is generally faster than Delete and also does not use as much Undo space as a Delete statement. If there are any associated triggers on the deleted table, then you should be aware that row-level delete triggers do not fire for a Truncate operation, while they do fire for a Delete operation.
     
    Sarah Reece, Sep 17, 2012 IP
  8. sywids

    sywids Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #48
    Sara Reece: Please share with me about trigger
     
    sywids, Sep 19, 2012 IP
  9. VanessaMeacham

    VanessaMeacham Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    3
    Trophy Points:
    36
    #49
    HI ! delete data from SQL table :

    DELETE FROM Persons WHERE LastName='Tjessem' AND FirstName='Jakob'

    Above syntax use when you want delete first and last name from table.

    DELETE FROM students it will delete whole table.

    Delete data from PHP :

    mysql_query("DELETE FROM Persons WHERE LastName='Griffin'");
     
    VanessaMeacham, Oct 8, 2012 IP
  10. sywids

    sywids Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #50
    Vanessa ....do you know about trigger in mySQL ?
     
    sywids, Oct 9, 2012 IP
  11. VanessaMeacham

    VanessaMeacham Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    3
    Trophy Points:
    36
    #51
    Hi sywids ! i know about the trigger. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. MySQL triggers are activated by SQL statements only.

    • Triggers are not activated by changes in INFORMATION_SCHEMA tables, because these tables are actually views.
    • Triggers are not activated by updates made using the NDB API.
     
    VanessaMeacham, Oct 9, 2012 IP