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

SQL addition, deletion, modification and search

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Data definition language DDL

Create table Student

(

Sno varchar2 (3) not null

Sname varchar2 (8) not null

Ssex varchar2 (2) not null

Sbirthday date

Sclass varchar2 (5)

)

2. Data manipulation language: add (insert into), modify (update set), delete data from the table (delete)

1.-- add data

Insert into student (sno,sname,ssex) values ('102 girls,' Zhang San, 'male')

-- or write this

Insert into student values ('102 Zhangsan', 'male', sysdate,'95033')

2.Mutual-data modification

Update student set ssex=' female 'where sno='102'

-- if you do not add where, you will modify the properties of a column of the entire table.

-- addition and subtraction of a column of data

Update student set sclass=sclass+1

Update table name set column name = column name + 1 where condition

3.Mutual-deletion of data

Delete from student where sno=102

Delete from table name where condition

-- delete the entire table without adding where, but it is inefficient. You can delete it with the name of the truncate table table (delete the table first, then create the table)

Example: truncate table student

Third, data query language DQL: get data from tables (query data).

-- data query

Select * from table name

-- find fields according to conditions

Select sno,sname from student where sclass='95031'

Select field name from table name where condition

Physical deletion and logical deletion

Physical deletion of records, that is, data records in the database will be cleared directly (or deleted on disk), physical space will be released, and deleted data records can no longer be searched from the database. The deletion of the delete statement in the database is the physical deletion of the logical record, which does not delete the data in the database directly, but only shields the display of the logically deleted data in the foreground by some means, does not release the physical space, and can also find the data from the database.

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