达梦数据库常用sql
时间: 2024-11-29 10:14:59 浏览: 50
达梦数据库(DAMO)是一种国产的关系型数据库管理系统,SQL(Structured Query Language)是其查询语言。以下是使用DAMO数据库的一些常见SQL命令:
1. **创建表**: 创建用户表:
```sql
CREATE TABLE Users (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Email VARCHAR(100)
);
```
2. **插入数据**:
```sql
INSERT INTO Users (ID, Name, Email) VALUES (1, '张三', 'zhangsan@example.com');
```
3. **查询数据**:
- 查询所有信息:
```sql
SELECT * FROM Users;
```
- 根据条件查询特定信息:
```sql
SELECT Name, Email FROM Users WHERE ID = 1;
```
4. **更新数据**:
```sql
UPDATE Users SET Email = 'zhangsan_new@example.com' WHERE ID = 1;
```
5. **删除数据**:
```sql
DELETE FROM Users WHERE ID = 1;
```
6. **连接操作** (JOIN):
```sql
SELECT A.Name, B.Age FROM Users A JOIN User_Ages B ON A.ID = B.UserID;
```
7. **分组和聚合函数** (GROUP BY, COUNT, SUM等):
```sql
SELECT City, COUNT(*) as UserCount FROM Users GROUP BY City;
```
阅读全文