Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5Zmj-00005W-Cc for pgsql-general@arkaria.postgresql.org; Sat, 22 Feb 2020 18:45:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j5Zmg-0005Q9-UC for pgsql-general@arkaria.postgresql.org; Sat, 22 Feb 2020 18:45:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5Zmf-0005JJ-5R for pgsql-general@lists.postgresql.org; Sat, 22 Feb 2020 18:45:50 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j5ZmY-0005dD-CT for pgsql-general@lists.postgresql.org; Sat, 22 Feb 2020 18:45:44 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 491DC21B2C; Sat, 22 Feb 2020 13:45:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 22 Feb 2020 13:45:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=t Po92fz26QV6GWV3IAur4sZ48JOAn5YaOjh/lngx2pg=; b=W4g4IZTGdKF5K3FID KJTVcSCa2XcyC4tOLuH1za4SJA7RqmSHg8oqhFNx0/mZ2cRjbUd1Jpy1nTYG8MYw 0qH9JHMdUGh7gZGvhGMyjOGZZZD98Z5MD9Bi7NtlLNpMQ2bG0zWfPtFseSfou/JJ x7viX5freOps/HNwcX29I14lnw5GYqOAWO3wZGTcanXupT+2kY+X+f0+ypyRPBVb FjPNJc72bNtEL4GDePtZ5vjk05UVbNhqQjbkOS9LjshJS2f/BufR5Ig22SggWv4K TW/bLEZwWRc3VEj4xC8Ng1VllvpJfbUG28R5WF2F2pnEqWijZxrKYMgu4qX2O62T eLCuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=tPo92fz26QV6GWV3IAur4sZ48JOAn5YaOjh/lngx2 pg=; b=bQbTMds9+QBlnce8iqzQ4tLYQASdEBuLcbabYKKgUYHcFWRol8O5Aoe5H 85CBSSaq7R3bb9KaEaulSL2ngQW7tFPRJ5IQJlUziRznBh19gdtpIlhnysh7PfF3 6VfGYxcxzSx6sgbdz2jvuf68QWeHVxXi8v1H90/xg4gk5DN/0oNJI8WQDLSGkxn6 MDq56r8OHyEnFDX5HIFekFiuAsn2XHGI1Xe5ZoL+fkFd5g3FdVGSxvP+F7yqIAaj 7JDkRuYP/gcMq1jpJlH37k5Q83mc52h3KyWpj4pBA1Ca0roNH9Zleu4Dp2JS2ECI ip5OSGrlvtjvJHAnofgBSj058nV0g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkeeigdduudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefheenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvddu vddruddvledrudelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 4E6B33060BE4; Sat, 22 Feb 2020 13:45:40 -0500 (EST) Subject: Re: how to find a tablespace for the table? To: Daulat Ram , "pgsql-general@lists.postgresql.org" References: From: Adrian Klaver Message-ID: <4dc3920a-264c-a33d-15a4-dba5ad60b98a@aklaver.com> Date: Sat, 22 Feb 2020 10:45:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/22/20 10:34 AM, Daulat Ram wrote: > Hi team, > > how to find a tablespace for the table? > > See my comments below: > > I have created a database with default tablespace like below: > > edb=# CREATE DATABASE conndb WITH TABLESPACE = conn_s_tables; > > After that I have created a table > > CREATE TABLE COMPANY_new( > >    ID INT PRIMARY KEY     NOT NULL, > >    NAME           TEXT    NOT NULL, > >    AGE            INT     NOT NULL, > >    ADDRESS        CHAR(50), > >    SALARY         REAL, > >    JOIN_DATE        DATE > > ) , > > CREATE TABLE COMPANY_new( > >    ID INT PRIMARY KEY     NOT NULL, > >    NAME           TEXT    NOT NULL, > >    AGE            INT     NOT NULL, > >    ADDRESS        CHAR(50), > >    SALARY         REAL, > >    JOIN_DATE        DATE > > ) > > tablespace conn_s_tables ; > > But I am unable to search the tablespace name where tablespace exist , > tablespace column is blank. https://www.postgresql.org/docs/12/view-pg-tables.html tablespace name pg_tablespace.spcname Name of tablespace containing table (null if default for database) https://www.postgresql.org/docs/12/sql-createdatabase.html tablespace_name The name of the tablespace that will be associated with the new database, or DEFAULT to use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. See CREATE TABLESPACE for more information. So conn_s_tables is default for conndb, therefore it will not show up in queries below. If you want to find the default tablespace: https://www.postgresql.org/docs/12/catalog-pg-database.html dattablespace oid pg_tablespace.oid The default tablespace for the database. Within this database, all tables for which pg_class.reltablespace is zero will be stored in this tablespace; in particular, all the non-shared system catalogs will be there. > > conndb=# select schemaname,tablename,tableowner,tablespace from > pg_tables where tablename='company'; > > schemaname | tablename |  tableowner  | tablespace > > ------------+-----------+--------------+------------ > > conndb     | company   | enterprisedb | > > (1 row) > > conndb=# select schemaname,tablename,tableowner,tablespace from > pg_tables where tablename='company_new'; > > schemaname |  tablename  |  tableowner  | tablespace > > ------------+-------------+--------------+------------ > > conndb     | company_new | enterprisedb | > -- Adrian Klaver adrian.klaver@aklaver.com