Summary of common database problems

What does the title index do? And what are its advantages and disadvantages?

The index is a special lookup table, which can be used to accelerate the retrieval of data when searching the database. It is very similar to a catalog of books in real life. You can find the data you want without querying the entire book. Indexes can be unique. Creating an index allows you to specify a single column or multiple columns. The disadvantage is that it slows down the speed of data entry and also increases the size of the database.

What kind of title field is suitable for indexing

Unique, non-empty, frequently queried field

What are the index types?

Logically:
Single column single row index
Concatenated multiple row index
Unique unique index
NonUnique non-unique index

What is a transaction? What is a lock?


Insert picture description here

The difference between primary key and foreign key?

The primary key in this table is unique and non-empty. Foreign keys can be repeated but empty; foreign keys are associated with the primary key of another table, and foreign keys that do not exist in the corresponding table cannot be created.

What is the difference between Varchar2 and varchar?

The length of Char is fixed, and the length of varchar2 can be changed. For example, storing the string "abc" for char(20) means that the character you store will occupy 20 bytes and contain 17 empty spaces, and the same Varchar2(20) only occupies 3 bytes, and 20 is only the maximum value. When the characters you store are less than 20, they are stored according to the actual length. The efficiency of char must be higher than the efficiency of varchar2. Currently varchar is a synonym for varchar2. The industry standard varchar type can store empty strings, but Oracle cannot do this, although it reserves the right to do so in the future. Oracle developed a data type varchar2, this type is not a standard varchar, he changed the characteristics of the varchar column in the database can store empty strings to store null values, if you want to have backward compatibility, Oracle recommends using varchar2 instead of varchar.

50 randomly selected from the database

select * from (select * from t_example order by dbms_random.random) where rownum <= 50

How to remove oracle duplication

Use distinct keyword

Guess you like

Origin blog.csdn.net/aaaqqq1234/article/details/108418231