
What exactly does SELECT database (); mean? - Stack Overflow
Feb 3, 2019 · select database() as database_name However, the as is optional (although I strongly recommend using it for column aliases). And nothing enforces a reasonable name. So: select database() l returns a result set with one row and one column. The column is called l and the value in the one row is the database name.
Get list of databases from SQL Server - Stack Overflow
Jul 8, 2014 · To list all available databases in MS-SQL Server using T-SQL, you can execute the following query: SELECT name, database_id, create_date FROM sys.databases; GO If you want to exclude system databases just add below condition in query: SELECT name, database_id, create_date FROM sys.databases WHERE database_id > 4; GO
Get all table names of a particular database by SQL query?
Oct 12, 2010 · Probably due to the way different sql dbms deal with schemas. Try the following. For SQL Server: SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='dbName' For MySQL: SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE …
Listing information about all database files in SQL Server
Executing following sql (It will only work when you don't have multiple mdf/ldf files for same database) SELECT db.name AS DBName, (select mf.Physical_Name FROM sys.master_files mf where mf.type_desc = 'ROWS' and db.database_id = mf.database_id ) as DataFile, (select mf.Physical_Name FROM sys.master_files mf where mf.type_desc = 'LOG' and db ...
How to give a user only select permission on a database
Dec 21, 2015 · Right click the Database in Management Studio. Choose Properties; Select Permissions; If your user does not show up in the list, choose Search and type their name; Select the user in the Users or Roles list; In the lower window frame, Check the Select permission under the Grant column
How to query the name of the current SQL Server database …
To get round this you need to create the SP in the Master database and mark the procedure as a System Procedure. The method of doing this differs between SQL Server versions but here's the method for SQL Server 2005 (it is possible to do in 2000 with the master.dbo.sp_MS_upd_sysobj_category function).
How do I get list of all tables in a database using TSQL?
Oct 6, 2008 · Any of the T-SQL code below will work in SQL Server 2019:-- here, you need to prefix the database name in INFORMATION_SCHEMA.TABLES SELECT TABLE_NAME FROM [MSSQL-TEST].INFORMATION_SCHEMA.TABLES; -- The next 2 ways will require you to point -- to the specific database you want to list the tables USE [MSSQL-TEST]; -- (1) Using sys.tables …
sql server - How to get the list of all database users - Stack Overflow
Sep 18, 2013 · Another note not to be missed is, the list in the SQL Server Management Studio normally shows Windows users in addition to SQL users, And I would like those users to be included as well. So far, I have been able to come up with the following query: SELECT * FROM sys.database_principals where (type='S' or type = 'U')
sql - Find all tables containing column with specified name - Stack ...
Hopefully this isn't a duplicate answer, but what I like to do is generate a sql statement within a sql statement that will allow me to search for the values I am looking for (not just the tables with those field names ( as it's usually necessary for me to then delete any info related to the id of the column name I am looking for):
postgresql - How to switch databases in psql? - Stack Overflow
Oct 17, 2010 · Listing and Switching Databases in PostgreSQL When you need to change between databases, you’ll use the \connect command, or \c followed by the database name as shown below: postgres=# \connect database_name postgres=# \c database_name Check the database you are currently connected to. SELECT current_database(); PostgreSQL List …