1 JDBCConnect to database6Step
- Load the JDBC driver
- Establish the database connection
- Create a statement object
- Execute a query
- Process the results
- 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.