Capillary metal tubes have attracted considerable interest for flexible electronics, portable devices, trace sampling, and detection. Tailoring the microstructure and wettability inside the capillary tubes is of paramount importance, yet it presents great difficulty because of the spatial confinement. Here, the coupling effect is revealed between the fluidic and electric field induced by bubble motion in a confined space during anodic oxidation. By controlling the bubble regeneration and flow rate, uniform and superhydrophilic TiO2 nanotube arrays are developed throughout the inner surface of an ultrafine Ti tube with a diameter of 0.4mm and length of 1000mm, equivalent to an aspect ratio of 2500 that is the largest value being ever reported. The inner surface of a capillary tube is further coated with a polytetrafluoroethylene layer and explored as a sensing needle for liquid detection in terms of concentration and species. This study provides an innovative approach to tailor the microstructure and wettability in a confined space for functional capillary tubes.