查詢某個用戶的表名的sql語句怎么寫
看個例子
SQL>select owner,table_name from dba_tables where owner='CLARK';
OWNER TABLE_NAME
------------------------------ ------------------------------
CLARK TB
CLARK TBL
SQL>select owner,table_name from all_tables where owner='CLARK';
OWNER TABLE_NAME
------------------------------ ------------------------------
CLARK TB
CLARK TBL
SQL>select owner,segment_name from dba_segments where owner='CLARK' and segment_type='TABLE';
OWNER SEGMENT_NAME
------------------------------ --------------
CLARK TBL
CLARK TB
SQL多表查詢語句怎么寫
SQL多表查詢語句的步驟如下:
我們需要準備的材料分別是:電腦、sql查詢器。
1、首先,打開sql查詢器,連接上相應的數據庫表,例如m1表和m2表。
2、點擊“查詢”按鈕,輸入:select max(km) from m1 join m2 on *=* where id=14 and lx=15;。
3、點擊“運行”按鈕,此時查詢到km的最大值為20。
數據庫查詢語句怎么寫
create table users
(
id int identity,
productid nvarchar(50)
)
insert into users values('1000,1001')
insert into users values('1000,1002,1001')
insert into users values('1001')
create table product
(
productid nvarchar(50),
price int
)
insert into product values('1000',10)
insert into product values('1001',20)
insert into product values('1002',15)
go
create function test
(
@str nvarchar(20)
)
returns int
as
begin
declare @price int
set @price=0
declare @temp table(value nvarchar(20))
while(CHARINDEX(',',@str)>0)
begin
insert into @temp values(SUBSTRING(@str,1,charindex(',',@str)-1))
set @str=SUBSTRING(@str,CHARINDEX(',',@str)+1,LEN(@str))
end
insert into @temp values(@str)
select @price = SUM(price) from product inner join @temp on *tid=[@temp].value
return @price
end
go
select id,*(productid) from users