Category: h2 Database

  • Khóa học miễn phí H2 Database – Explain nhận dự án làm có lương

    H2 Database – Explain



    EXPLAIN command displays the execution plan for a statement. When we execute a statement using EXPLAIN ANALYZE command, the query plan will include the actual row scan count for each table.

    Syntax

    Following is the generic syntax of the EXPLAIN command.

    EXPLAIN { [ PLAN FOR ] | ANALYZE } { select | insert | update | delete | merge}
    

    Along with this syntax we can use select, insert, delete, and merge.

    Example

    This example explains the query plan details of the customer with ID 1.

    EXPLAIN SELECT * FROM CUSTOMER WHERE ID = 1;
    

    The above command produces the following output −

    Explain Output

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí H2 Database – Insert nhận dự án làm có lương

    H2 Database – Insert



    The SQL INSERT statement is used to add new rows of data to a table in the database.

    Syntax

    Following is the basic syntax of INSERT INTO statement.

    INSERT INTO tableName
    { [ ( columnName [,...] ) ]
    { VALUES
    { ( { DEFAULT | expression } [,...] ) } [,...] | [ DIRECT ] [ SORTED ] select } } |
    { SET { columnName = { DEFAULT | expression } } [,...] }
    

    Using this INSERT statement, we can insert a new record or new rows into a table. When using DIRECT clause, the results are directly affected to the target table without any intermediate step. However, while adding values for all the columns of the table, make sure the order of the values is in the same order as the columns in the table.

    Example

    Let us take an example and try to insert the following given records into the Customer table.

    ID Name Age Address Salary
    1 Ramesh 32 Ahmedabad 2000
    2 Khilan 25 Delhi 1500
    3 Kaushik 23 Kota 2000
    4 Chaitail 25 Mumbai 6500
    5 Hardik 27 Bhopal 8500
    6 Komal 22 MP 4500
    7 Muffy 24 Indore 10000

    We can get all the given records into the customer table by executing the following commands.

    INSERT INTO CUSTOMER VALUES (1, ''Ramesh'', 32, ''Ahmedabad'', 2000);
    INSERT INTO CUSTOMER VALUES (2, ''Khilan'', 25, ''Delhi'', 1500);
    INSERT INTO CUSTOMER VALUES (3, ''kaushik'', 23, ''Kota'', 2000);
    INSERT INTO CUSTOMER VALUES (4, ''Chaitali'', 25, ''Mumbai'', 6500);
    INSERT INTO CUSTOMER VALUES (5, ''Hardik'', 27, ''Bhopal'', 8500);
    INSERT INTO CUSTOMER VALUES (6, ''Komal'', 22, ''MP'', 4500);
    INSERT INTO CUSTOMER VALUES (7, ''Muffy'', 24, ''Indore'', 10000);
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí H2 Database – Call nhận dự án làm có lương

    H2 Database – Call



    CALL is a SQL command which belongs to H2 database server. This command is used to calculate a simple expression. It returns the result of the given expression in a single column field. When it returns an array of results, then each element in the array is displayed as a column value.

    Syntax

    Following is the generic syntax of the CALL command.

    CALL expression;
    

    We can use the arithmetic expression in this syntax.

    Example

    Let us take an example and execute an arithmetic expression (15 * 25) using call command.

    CALL 15*25;
    

    The above command produces the following output.

    375
    375

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí H2 Database – Backup nhận dự án làm có lương

    H2 Database – Backup



    BACKUP is the command used to take database backup into a separate .zip file. Objects are not locked, and when it takes backup the transaction log is also copied. Admin rights are required to execute this command.

    Syntax

    Following is the generic syntax of the Backup command.

    BACKUP TO fileNameString;
    

    Example

    In this example, let us take a backup of the current database into backup.zip file. Use the following command for the same.

    BACKUP TO ''backup.zip
    

    On executing the above command, you will get the backup.zip file in your local file system.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc