The purpose of the study is to find out if the new tablet formulation oral semaglutide D is equally safe and effective as the approved oral semaglutide for treating Japanese people with type 2 diabetes. Participants will receive either oral semaglutide D (the treatment being tested) or oral semaglutide (the comparator); which treatment a participant gets is decided by chance. Oral semaglutide is an approved tablet (a treatment used as a comparator), while oral semaglutide D is described as the new tablet formulation being tested in this study. The study will last approximately 27 weeks.