-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[10.x] Get tables and views info #49020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
dde7943
f118ed3
c207562
f12b725
803c82b
b6f8f8a
af3c387
342b263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,13 +69,42 @@ public function compileDropDatabaseIfExists($name) | |
/** | ||
* Compile the query to determine if a table exists. | ||
* | ||
* @deprecated Will be removed in a future Laravel version. | ||
* | ||
* @return string | ||
*/ | ||
public function compileTableExists() | ||
{ | ||
return "select * from sys.sysobjects where id = object_id(?) and xtype in ('U', 'V')"; | ||
} | ||
|
||
/** | ||
* Compile the query to determine the tables. | ||
* | ||
* @return string | ||
*/ | ||
public function compileTables() | ||
{ | ||
return 'select t.name as name, SCHEMA_NAME(t.schema_id) as [schema], sum(u.total_pages) * 8 * 1024 as size ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hafezdivandari Why are you multiplying by 8 specifically here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because each page is 8 KB according to docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hafezdivandari But why not just multiply by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because that's more readable and easier to understand imo. |
||
.'from sys.tables as t ' | ||
.'join sys.partitions as p on p.object_id = t.object_id ' | ||
.'join sys.allocation_units as u on u.container_id = p.hobt_id ' | ||
.'group by t.name, t.schema_id ' | ||
.'order by t.name'; | ||
} | ||
|
||
/** | ||
* Compile the query to determine the views. | ||
* | ||
* @return string | ||
*/ | ||
public function compileViews() | ||
{ | ||
return 'select name, SCHEMA_NAME(v.schema_id) as [schema], definition from sys.views as v ' | ||
.'inner join sys.sql_modules as m on v.object_id = m.object_id ' | ||
.'order by name'; | ||
} | ||
|
||
/** | ||
* Compile the query to determine the list of columns. | ||
* | ||
|
@@ -507,6 +536,8 @@ public function compileDropAllViews() | |
/** | ||
* Compile the SQL needed to retrieve all table names. | ||
* | ||
* @deprecated Will be removed in a future Laravel version. | ||
* | ||
* @return string | ||
*/ | ||
public function compileGetAllTables() | ||
|
@@ -517,6 +548,8 @@ public function compileGetAllTables() | |
/** | ||
* Compile the SQL needed to retrieve all view names. | ||
* | ||
* @deprecated Will be removed in a future Laravel version. | ||
* | ||
* @return string | ||
*/ | ||
public function compileGetAllViews() | ||
|
Uh oh!
There was an error while loading. Please reload this page.