Two-dimensional electron gas (2DEG) in interfaces and surfaces based on perovskite SrTiO3 (STO) has exhibited various interesting phenomena and is used to develop oxide electronics. Recently, KTaO3 (KTO) shows great potential and is believed to host more exciting effects and phenomena toward novel devices. Here, through first-principles investigation and analysis, we find two types of coexisting 2DEG and 2D hole gas (2DHG) highly confined at the interfaces in undoped STO/KTO/BaTiO3 heterostructures, when the KTO thickness m reaches a crititcal value. The two interfaces are made by (SrO) 0 /(TaO2) + and (KO) − /(TiO2) 0 for the A-type, and by (TiO2) 0 /(KO) − and (TaO2) + /(BO) 0 for the B-type. The 2D electron carriers originate from Ta-5dxy states at the interface including TaO2 atomic layer, and the hole carriers from O-2px/py orbitals at the other interface. The electron and hole effective masses are 0.3m0 and 1.06 ∼ 1.12m0, respectively, where m0 is mass of free electron, and the 2D carrier concentrations are in the order of 10 13 cm −2 . Our analysis indicates that the interfacial 2DEG and 2DHG are simultaneously formed because of the band bending due to the polar discontinuity at the interfaces and the stress-induced polarization within the KTO layer. These could stimulate more exploration for new phenomena and novel devices.