Skip to main content

Posts

Showing posts with the label Truncate

JDBC program for truncate table

 JDBC program for truncate table for explanation watch video:: Before Execution Of Program:: SQL> select * from test1;        EID ENAME ---------- ----------          1 raja          2 Jhon CODE:: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.*; public class College { public static void main(String[] args)throws Exception{ Connection con =  DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger"); Statement st = con.createStatement(); //write query String query = "truncate table test1"; //execute  int count = st.executeUpdate(query); if(count==0){ System.out.println("Table is truncated"); }else{ System.out.println("Table is not truncated"); } con.close(); } } After Execution of Program:: ====================== SQL> select * from test1;

Truncate Command (DDL) in SQL Oracle With Implementation

 Truncate Command (DDL) in SQL Oracle With Implementation For Explanation Watch Video:: Truncate:    -TO delete all rows from table at a time    - Deleting rows but not column    - By using this cmd we cant delete specific row from table    -It doesnt support where clause EX::: SQL> create table emp01(fname varchar2(10),sal Number(10)); Table created. SQL> insert into empo1 values('miller',500000); insert into empo1 values('miller',500000)             * ERROR at line 1: ORA-00942: table or view does not exist SQL> insert into emp01 values('miller',500000); 1 row created. SQL> insert into emp01 values('Baburao',50000); 1 row created. SQL> insert into emp01 values('Smith',500000); 1 row created. SQL> select * from emp01; FNAME             SAL ---------- ---------- miller         500000 Baburao         50000 Smith          500000 SQL> truncate table emp01; Table truncated. After Truncate:: SQL> select * from emp01; no rows se