How do I select from a table within a specific schema?
조회 수: 30 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 9월 15일
답변: MathWorks Support Team
2021년 2월 1일
I would like to query a table in a database under a specific schema. In Database Explorer, I can select the schema in the Data Browser panel. How do I do this programmatically?
채택된 답변
MathWorks Support Team
2020년 9월 15일
This would depend on which command you are using to query the database:
If you are using 'sqlread', you can specify it as a argument:
tablename = 'productTable';
data = sqlread(conn,tablename,'Schema','dbo');
If you are using 'fetch' or 'select', then in your SQL statement, you specify the schema with the table name:
results = fetch(conn, 'SELECT * FROM schemaName.inventoryTable');
You can find more information regarding the SQL statement syntax in the documentation for your database. For SQL Server, we see this syntax explained here:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!