Three to six years at most. The duration depends on the research topics. In "exact" sciences (mathematics, physics, chemistry, biology, engineering, and others), research lasts three years, sometimes extended to four. In social sciences (law, management, archaeology, etc.), research lasts from four to five years. You must register again every year to your PhD/"doctoral" institution. For the first three years, the re-registrations almost automatic, but then you must complete a file to reregister for an additional year. Files are not accepted automatically. The doctoral school may ask in your file how many pages you have written so far for your thesis, what is the detailed plan of your thesis, and what is your projected timetable regarding the end of your thesis. The idea is to do everything so you can finish your thesis as soon as possible, and in six years at most.
Researcher