Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic operation of database

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Display query results using sorting function

Order by [column name] desc; # desc indicates descending order, asc indicates ascending order

Example: select * from table name where ID = '001' order by createtime desc

Createtime (creation time), which is displayed in ascending order by default and converted to descending order using order by [column name] desc

Display the results of multiple query statements in one window: union all

-example: display the following three results in the same window-

Select * from table name where ID = '001' union all

Select * from table name where ID = '002' union all

Select * from table name where ID = '003'

3. Multi-table association query: select from Table 1 where ID in (select ID from Table 2)

Example: select from Table 1 where ID in (select ID from Table 2)

4. View the database version: select * from v$version

5. Delete a row in the table delete from table name where condition 1.

Delete from table name where ID= '001'

Tip: use the select statement to confirm whether the deletion condition is unique before deletion

Select * from table name where ID = '001'

6. Modify the contents of the table

Update table name set modified content where condition 1.

Update table name set ID = '002' where ID = '001';-- change 001 to 002

7. Replacement function replace (field name, 'source', 'destination')

1. Start with the select field name, replace (field name, '00001') from table name where condition 1...

The 2.update table name set field name = replace (field name,'00 records, 01') where condition 1...

-- replace the specified content

-- query

Select name,replace (name,' Guangxi', 'Guangxi Zhuang Autonomous region') from name 1 where condition 1.

-- replace

Update table name 1 set name=replace (name,' Guangxi', 'Guangxi Zhuang Autonomous region') where condition 1.

8. Time calculation question:

Take March 7, 2018 as an example, plus 90 days 2018-06-05 00:00:00

Select to_date ('2018-03-07 00 from dual;) + 90 from dual;-accurate to minutes and seconds

Select to_date ('2018-03-07 minutes and seconds) + 90 from dual;

9.=distinct is weighed and then count () =

SELECT COUNT () AS test FROM, test (custom name)

SELECT COUNT (*) AS test FROM (select distinct zjhm from visit_contents where date > = '20160101' and date

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report