database-table

How do I get list of all tables in a database using TSQL?

耗尽温柔 提交于 2019-11-25 23:38:23
问题 What is the best way to get the names of all of the tables in a specific database on SQL Server? 回答1: SQL Server 2005, 2008, 2012, 2014, 2016, 2017 or 2019: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' To show only tables from a particular database SELECT TABLE_NAME FROM <DATABASE_NAME>.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Or, SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='dbName' --(for MySql,

Search All Fields In All Tables For A Specific Value (Oracle)

有些话、适合烂在心里 提交于 2019-11-25 22:27:09
问题 Is it possible to search every field of every table for a particular value in Oracle? There are hundreds of tables with thousands of rows in some tables so I know this could take a very long time to query. But the only thing I know is that a value for the field I would like to query against is 1/22/2008P09RR8 . < I\'ve tried using this statement below to find an appropriate column based on what I think it should be named but it returned no results. SELECT * from dba_objects WHERE object_name

How do I specify unique constraint for multiple columns in MySQL?

一世执手 提交于 2019-11-25 21:43:50
问题 I have a table: table votes ( id, user, email, address, primary key(id), ); Now I want to make the columns user, email, address unique (together). How do I do this in MySql? Of course the example is just... an example. So please don\'t worry about the semantics. 回答1: ALTER TABLE `votes` ADD UNIQUE `unique_index`(`user`, `email`, `address`); 回答2: I have a MySQL table: CREATE TABLE `content_html` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_box_elements` int(11) DEFAULT NULL, `id_router` int(11)

How does the search_path influence identifier resolution and the “current schema”

末鹿安然 提交于 2019-11-25 21:43:12
问题 Is it possible to define in which schema new tables get created by default? (Referred by \"unqualified table names\".) I\'ve seen some details about using the \"search path\" in Postgres, but I think it only works while retrieving data, not creating. I have a bunch of SQL scripts, which create many tables. Instead of modifying the scripts, I want to set the database create tables in a specific schema by default - when they have unqualified names. Is this possible? 回答1: Search path is indeed