I just want to get rid of the content in one table

Bit-101 136 Reputation points
2022-04-27T14:02:10.397+00:00

I took a chance that this was the right forum. The database is IBM DB2
But I think the query itself is the same as it is for SQL Database.
I just want to get rid of the content in one table and as I can see it´s only one ROW with 4 columns.
Columns:
JOBISRUNNING | STARTTEDTIM | COMPLETEDTIME | STARTBYPERON_REF

How should the query look exactly

The Table is called JOBBSTATUS

Really appreciate your answer

Developer technologies | Transact-SQL
{count} votes

3 answers

Sort by: Most helpful
  1. Bert Zhou-msft 3,436 Reputation points
    2022-04-28T01:47:02.583+00:00

    Hi,@Bit-101

    Welcome to Microsoft T-SQL Q&A Forum!

    197154-image.png
    To answer the question first, here is the forum for sql server . For IBM DB2 follow this link , if you have more complex IBM questions , it is recommended to consult the forum.

    197105-image.png
    From your description , it seems that you want to delete some columns in the table , which is easy to achieve , IBM database on this part is the same with TSQL use.

    You can try this:

    DELETE [FROM] [database_name.]table_name [ WHERE where_conditions ]  
      
    DELETE table_ref FROM [joined_table_refs] [ WHERE where_conditions ]  
    

    The first form evaluates rows in a table against an optional WHERE clause and deletes all rows that match the WHERE condition , or all rows if WHERE is omitted.
    And The second form evaluates one or more join clauses and deletes all matching rows from one of the tables . The join clause can contain non-Kudu tables , but the table from which the row is deleted must be a Kudu table . In this case , the FROM keyword is required to separate the name of the table whose rows are to be deleted from the table name of the join clause.

    Here I don't know what the column names of your table mean , I guess you can use where condition to complete the filtering you need, like this:

    Select JOBISRUNNING,STARTTEDTIM,COMPLETEDTIME, STARTBYPERON_REF  
    From JOBBSTATUS  
    Where STARTTEDTIM Between ----AND------  
    

    If you want to filter out records whose date is greater than a certain time period , you can change:

    Where table_column> timestamp ('date') ----The date here stores data in date format  
    

    Okay, the above is part of what I know about using DB2 , I hope it can help you .

    Best regards,
    Bert Zhou


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Olaf Helper 47,441 Reputation points
    2022-04-27T14:10:32.333+00:00

    I just want to get rid of the content in one table

    It's a simple DELETE statement, see https://www.w3schools.com/sql/sql_delete.asp

    0 comments No comments

  3. Michael Taylor 60,326 Reputation points
    2022-04-27T14:12:09.903+00:00

    You want to delete a row from a table? That is the delete command.

    DELETE FROM JOBBSTATUS [WHERE condition]
    

    If you wanted to delete everything then leave off the WHERE clause but you should be very careful with that.

    A more efficient way to remove all rows from a table is to use Truncate instead.

    TRUNCATE TABLE JOBBSTATUS...
    

    Refer to the docs for options related to how the system should react to removing all the rows.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.