Database Fundamentals #7: Create a Table Using T-SQL
The syntax for creating a table logically follows many of the same steps that you did when using the GUI,...
2017-08-07
294 reads
The syntax for creating a table logically follows many of the same steps that you did when using the GUI,...
2017-08-07
294 reads
The syntax for creating a table logically follows many of the same steps that you did when using the GUI,...
2017-08-07
183 reads
OK guys. I think it’s way past time. A bunch of us have been keeping a secret from the rest...
2017-08-01
480 reads
OK guys. I think it’s way past time. A bunch of us have been keeping a secret from the rest...
2017-08-01
221 reads
I read a lot of self-help and improvement information. I’m always trying to hack my brain or my attitude to...
2017-08-18 (first published: 2017-07-31)
1,914 reads
I read a lot of self-help and improvement information. I’m always trying to hack my brain or my attitude to...
2017-07-31
351 reads
The whole idea behind databases is to store information, data, in order to look at it later. The place where...
2017-07-24
535 reads
We’re weeks away from another SQL Cruise. If you’ve never heard of this before, follow the link to read more....
2017-08-01 (first published: 2017-07-19)
1,785 reads
I was given the opportunity to do a little online interview. It’s primarily about promotion, but I thought I’d share...
2017-07-18
306 reads
Don’t let the ease of creating databases lull you into a false sense of security. They actually can be very...
2017-07-31 (first published: 2017-07-17)
2,286 reads
It is Friday, the queries are running, and nobody is watching the bill. That...
By Steve Jones
Annabel retired from Redgate Software this week. Across most of my career at Redgate,...
By Tim Radney
As a SQL Server DBA with years of experience tuning production environments, I’ve seen...
Wa:0817781222 Jl. Otto Iskandardinata No.37, Karanganyar, Kec. Subang, Kabupaten Subang, Jawa Barat 41211
Wa:0817781222 Jl. Ir. H. Juanda No.118, Lebakgede, Kecamatan Coblong, Kota Bandung, Jawa Barat 40132
Wa:0817781222 Jl. Ahmad Yani No.9, RT.01/RW.05, Marga Jaya, Kec. Bekasi Sel., Kota Bks, Jawa...
I set up a few users on my SQL Server 2022 instance.
CREATE LOGIN User1 WITH PASSWORD = 'Demo12#1' CREATE USER User1 FOR LOGIN User1 GO CREATE LOGIN User2 WITH PASSWORD = 'Demo12#2' CREATE USER User2 FOR LOGIN User2 GO CREATE LOGIN User3 WITH PASSWORD = 'Demo12#3' CREATE USER User3 FOR LOGIN User3 GOI then created a schema that one of them owned. Under this schema, I added a table with some data.
CREATE SCHEMA MySchema AUTHORIZATION User1
GO
CREATE TABLE Myschema.MyTable(myid INT)
GO
INSERT MySchema.MyTable
(
myid
)
VALUES
(1), (2), (3)
GO
SELECT * FROM MySchema.MyTable
GO
I granted rights and verified that User2 could access this table.
GRANT SELECT ON Myschema.MyTable TO User2 GO SETUSER 'USER2' GO SELECT * FROM MySchema.MyTable GOThis worked. Now, I move this schema to a new user.
ALTER AUTHORIZATION ON SCHEMA::Myschema TO User3; GOWhat happens with this code?
SETUSER 'USER2' GO SELECT * FROM MySchema.MyTable GOSee possible answers