JDBC knowledge Q &

Source: Internet
Author: User

1 JDBCConnect to database6Step

    1. Load the JDBC driver
    2. Establish the database connection
    3. Create a statement object
    4. Execute a query
    5. Process the results
    6. Close the connection

2Transaction4Features

Answer: atomicity A, consistency C, isolation I, permanent d

3. Select count(*)From studentAndSelect count(ID)From student.

Answer:

Select count (*) counts the number of records for all students, including null records.

Select count (ID) counts the number of records for all students, excluding null records.

4Suppose there are tablesSystem. Table1The table has three fields:ID (Numeric type),Name(Balanced ),Age(Numeric) WriteSQLStatement to complete the following functions: find in the table that the age is greater20And the name is"Wang"Records at the beginning are arranged in descending order of age (older records are at the beginning ).

Answer:

Select * from system. Table1 where age> 20 and name like 'King % 'order by age DESC;

5.CreateMERsTable with the following fields:ID(Non-null, primary key)Bigint,Name(Not empty)Varchar,Age:IntType; createOrdersTable with the following fields:ID(Non-null, primary key ,)Bigint,Order_number(Not empty)Varchar,Price:Double,Customer_id(Foreign key)Bigint, Sets the cascading deletion;

Answer: Create Table custombers (

Id bigint not null,

Name varchar (15 ),

Age int,

Primary Key (ID)

);

Create Table orders (

Id bigint not null,

Order_number varchar (15) Not nulll,

Price double precision,

Customer_id bigint,

Primary Key (ID ),

);

Alter table orders add constraint fk_customer foreign key (mermer_id) References MERs (ID) on Delete cascade;

6.Use left outer join to query,OrdersAndMERsTable,

Answer: Select C. ID, O. customer_id, C. Name, O. ID order_id, order_number from customers C left Outer Join orders o no C. ID = O. customer_id;

29. Briefly describe the lifecycle of database transactions? (Flowcharts can be drawn)

Answer:

 

 

7. Delete from tablea & truncate table tableaDifference

Truncate statements are executed quickly, occupy less resources, and only logs deleted from pages are recorded;

Delete: logs are required to delete each record.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.