Oracle数据库递归查询(start with)

本文介绍了如何在Oracle数据库中进行递归查询,包括从根节点和子节点开始查询所有节点信息的方法。通过`start with`和`connect by`子句实现递归,详细解析了这两个关键字的使用技巧,并提供了查询语句示例及结果展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

数据库递归查询

表结构包含递归关系【建表语句】

		-- Create table
		create table t_goods_category
		(
		  id            VARCHAR2(32) not null,
		  pid           VARCHAR2(32),
		  name          VARCHAR2(32),
		  img_url       VARCHAR2(100),
		  status        VARCHAR2(1) default '0'
		)
		tablespace CMNT_LIFE_TICKET;
		
		-- Add comments to the table 
		comment on table t_goods_category
		  is '商品分类';
		-- Add comments to the columns 
		comment on column t_goods_category.id
		  is '主键';
		comment on column t_goods_category.pid
		  is '父id';
		comment on column t_goods_category.name
		  is '名称';
		comment on column t_goods_category.img_url
		  is '图片地址';
		comment on column t_goods_category.status
		  is '状态 0-未使用 1-使用 ';
		  
		-- Create/Recreate primary, unique and foreign key constraints 
		alter table t_goods_category
		  add constraint t_goods_category_PK primary key (ID)
		  using index 
		  tablespace CMNT_LIFE_TICKET_INDEX
		  ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值